wax-ws-rpc-js 1.0.0 → 1.0.1
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 +65 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,2 +1,66 @@
|
|
|
1
|
-
# wax-ws-rpc-js
|
|
1
|
+
# wax-ws-rpc-js
|
|
2
2
|
JavaScript client SDK for WAX WebSocket RPC.
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
|
|
6
|
+
### NPM
|
|
7
|
+
|
|
8
|
+
The official distribution package can be found at [npm](https://www.npmjs.com/package/wax-ws-rpc-js).
|
|
9
|
+
```bash
|
|
10
|
+
npm install wax-ws-rpc-js
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Import
|
|
14
|
+
|
|
15
|
+
### ES Modules
|
|
16
|
+
|
|
17
|
+
Importing using ESM syntax is supported using TypeScript, [webpack](https://webpack.js.org/api/module-methods)
|
|
18
|
+
```js
|
|
19
|
+
import { WebsocketJsonRpc } from "wax-ws-rpc-js";
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### CommonJS
|
|
23
|
+
|
|
24
|
+
Importing using commonJS syntax is supported by Node.js
|
|
25
|
+
```js
|
|
26
|
+
const { WebsocketJsonRpc } = require("wax-ws-rpc-js");
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Basic Usage
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
const rpc = new WebsocketJsonRpc('ws://localhost:3000');
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Chain API Request
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
const info = await rpc.get_info();
|
|
39
|
+
|
|
40
|
+
const table_rows = await rpc.get_table_rows({
|
|
41
|
+
"json": true,
|
|
42
|
+
"code": "eosio.token",
|
|
43
|
+
"scope": "eosio.saving",
|
|
44
|
+
"table": "accounts"
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const account = await rpc.get_account("eosio");
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Using With eosjs
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import { Api } from 'eosjs';
|
|
54
|
+
import { WebsocketJsonRpc } from 'wax-ws-rpc-js';
|
|
55
|
+
|
|
56
|
+
const rpc = new WebsocketJsonRpc('ws://localhost:3000');
|
|
57
|
+
const api = new Api({
|
|
58
|
+
rpc,
|
|
59
|
+
textDecoder: new TextDecoder(),
|
|
60
|
+
textEncoder: new TextEncoder()
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
[](https://labs.wax.io/proposals/239)
|