@psalomo/jsonrpc-client 0.1.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 +43 -0
- package/dist/browser-standalone.js +13651 -0
- package/dist/index.d.mts +241 -0
- package/dist/index.d.ts +241 -0
- package/dist/index.js +367 -0
- package/dist/index.mjs +339 -0
- package/package.json +58 -0
package/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# `@near-js/jsonrpc-client`
|
2
|
+
|
3
|
+
This package provides a fully-typed client for the NEAR Protocol JSON-RPC API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```bash
|
8
|
+
pnpm add @near-js/jsonrpc-client
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Create a new client instance and call any of the available RPC methods:
|
14
|
+
|
15
|
+
```typescript
|
16
|
+
import { JsonRpcClient } from '@near-js/jsonrpc-client';
|
17
|
+
|
18
|
+
const client = new JsonRpcClient({ url: 'https://rpc.mainnet.near.org' });
|
19
|
+
|
20
|
+
async function getNetworkStatus() {
|
21
|
+
const status = await client.status();
|
22
|
+
console.log('Network status:', status);
|
23
|
+
}
|
24
|
+
|
25
|
+
getNetworkStatus();
|
26
|
+
```
|
27
|
+
|
28
|
+
### Handling Responses
|
29
|
+
|
30
|
+
All method calls return a promise that resolves to a result object. The result object is fully typed based on the JSON-RPC API specification.
|
31
|
+
|
32
|
+
```typescript
|
33
|
+
import { JsonRpcClient } from '@near-js/jsonrpc-client';
|
34
|
+
|
35
|
+
const client = new JsonRpcClient({ url: 'https://rpc.mainnet.near.org' });
|
36
|
+
|
37
|
+
async function getLatestBlock() {
|
38
|
+
const block = await client.block({ finality: 'final' });
|
39
|
+
console.log('Latest block:', block);
|
40
|
+
}
|
41
|
+
|
42
|
+
getLatestBlock();
|
43
|
+
```
|