@zuhaibnoor/zigchain-sdk 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 +107 -0
- package/package.json +5 -2
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Quick Usage Guide
|
|
2
|
+
|
|
3
|
+
## Bank Module
|
|
4
|
+
|
|
5
|
+
Import the Bank API and network endpoints:
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import {
|
|
9
|
+
ChainBankApi,
|
|
10
|
+
getNetworkEndpoints,
|
|
11
|
+
Network,
|
|
12
|
+
} from '@zuhaibnoor/zigchain-sdk'
|
|
13
|
+
````
|
|
14
|
+
|
|
15
|
+
Initialize the Bank API:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
const endpoints = getNetworkEndpoints(Network.Testnet)
|
|
19
|
+
const bankApi = new ChainBankApi(endpoints)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Fetch all balances of an address
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
const address = 'zig1xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
|
26
|
+
|
|
27
|
+
const balances = await bankApi.fetchBalances(address)
|
|
28
|
+
console.dir(balances, { depth: null })
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Fetch balance of a specific denom
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
const balance = await bankApi.fetchBalance(address, 'uzig')
|
|
35
|
+
console.dir(balance, { depth: null })
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Fetch total supply of all tokens
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
const supply = await bankApi.fetchTotalSupply()
|
|
42
|
+
console.dir(supply, { depth: null })
|
|
43
|
+
````
|
|
44
|
+
|
|
45
|
+
### Fetch supply of a specific token denomination
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
const supplyOf = await bankApi.fetchSupplyOf('uzig')
|
|
49
|
+
console.dir(supplyOf, { depth: null })
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Fetch metadata of a specific denom
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
const metadata = await bankApi.fetchDenomMetadata('uzig')
|
|
57
|
+
console.dir(metadata, { depth: null })
|
|
58
|
+
````
|
|
59
|
+
|
|
60
|
+
### Fetch owners of a specific denom
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
const owners = await bankApi.fetchDenomOwners('uzig')
|
|
64
|
+
console.dir(owners, { depth: null })
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Fetch metadata of all denoms
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
const allMetadata = await bankApi.fetchAllDenomsMetadata()
|
|
71
|
+
console.dir(allMetadata, { depth: null })
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Fetch send-enabled denoms
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
const sendEnabled = await bankApi.fetchSendEnabled()
|
|
78
|
+
console.dir(sendEnabled, { depth: null })
|
|
79
|
+
````
|
|
80
|
+
|
|
81
|
+
### Fetch spendable balance of a specific denom
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
const spendable = await bankApi.fetchSpendableBalance(address, 'uzig')
|
|
85
|
+
console.dir(spendable, { depth: null })
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Fetch all spendable balances of an address
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
const spendableBalances = await bankApi.fetchSpendableBalances(address)
|
|
92
|
+
console.dir(spendableBalances, { depth: null })
|
|
93
|
+
````
|
|
94
|
+
|
|
95
|
+
### Fetch bank module parameters
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const paramsAtHeight = await bankApi.fetchParams()
|
|
99
|
+
console.dir(paramsAtHeight, { depth: null })
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuhaibnoor/zigchain-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
8
11
|
"scripts": {
|
|
9
12
|
"build": "tsc",
|
|
10
13
|
"dev": "tsc --watch",
|