@tezos-x/octez.js-rpc 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # octez.js RPC package
2
+
3
+ *Documentation can be found [here](https://octez.js.io/docs/rpc_package)*
4
+ *TypeDoc style documentation is available on-line [here](https://octez.js.io/typedoc/modules/_octez.js_rpc.html)*
5
+
6
+ **Maintained by [Nomadic Labs](https://www.nomadic-labs.com/).**
7
+
8
+ `@tezos-x/octez.js-rpc` is an npm package that provides low-level methods and types to invoke RPC calls from a Tezos RPC node.
9
+
10
+ ## General Information
11
+
12
+ The RPC package can be used to query the RPC API of your chosen node. Methods in the RPC package map one-to-one to the corresponding Tezos RPC API endpoints. All responses from the RPC are returns with TypeScript types.
13
+
14
+ The higher-level `@tezos-x/octez.js` package builds on this RPC package.
15
+
16
+ ## Install
17
+
18
+ ```
19
+ npm i --save @tezos-x/octez.js-rpc
20
+ ```
21
+
22
+ ## Usage
23
+ ### RpcClient
24
+
25
+ The constructor of the `RpcClient` takes an RPC URL as a parameter and an optional chain (default is main).
26
+
27
+ ```ts
28
+ import { RpcClient } from '@tezos-x/octez.js-rpc';
29
+
30
+ const client = new RpcClient('https://YOUR_PREFERRED_RPC_URL');
31
+
32
+ // Fetching the balance of an account in mutez (micro ꜩ)
33
+ const balance = await client.getBalance('tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb');
34
+ ```
35
+
36
+ ### RpcClientCache
37
+
38
+ The `RpcClientCache` class aims to improve the performance of dApps built using octez.js by reducing the number of calls made to the RPC. Its constructor takes a RpcClient instance as a parameter and an optional ttl (time to live). The RpcClient responses will be cached for the period defined by the ttl (default is of 1000 milliseconds). The `RpcClientCache` can be injected to the TezosToolkit as follow:
39
+
40
+ ```ts
41
+ import { TezosToolkit } from '@tezos-x/octez.js';
42
+ import { RpcClient, RpcClientCache } from '@tezos-x/octez.js-rpc';
43
+
44
+ const rpcClient = new RpcClient('https://YOUR_PREFERRED_RPC_URL');
45
+ const tezos = new TezosToolkit(new RpcClientCache(rpcClient));
46
+ ```
47
+
48
+ ## Additional info
49
+
50
+ See the top-level project [https://github.com/trilitech/octez.js](https://github.com/trilitech/octez.js) for details on reporting issues, contributing and versioning.
51
+
52
+ ## Disclaimer
53
+
54
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.