@zuhaibnoor/zigchain-sdk 1.0.2 → 1.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/dist/auth/ChainAuthApi.d.ts +0 -3
- package/dist/auth/ChainAuthApi.d.ts.map +1 -1
- package/dist/auth/ChainAuthApi.js +0 -26
- package/dist/auth/ChainAuthApi.js.map +1 -1
- package/dist/bank/ChainBankApi.d.ts +0 -9
- package/dist/bank/ChainBankApi.d.ts.map +1 -1
- package/dist/bank/ChainBankApi.js +0 -18
- package/dist/bank/ChainBankApi.js.map +1 -1
- package/dist/client/http.d.ts +1 -0
- package/dist/client/http.d.ts.map +1 -1
- package/dist/client/http.js +10 -0
- package/dist/client/http.js.map +1 -1
- package/dist/distribution/ChainDistributionApi.d.ts +47 -0
- package/dist/distribution/ChainDistributionApi.d.ts.map +1 -0
- package/dist/distribution/ChainDistributionApi.js +75 -0
- package/dist/distribution/ChainDistributionApi.js.map +1 -0
- package/dist/distribution/types.d.ts +71 -0
- package/dist/distribution/types.d.ts.map +1 -0
- package/dist/distribution/types.js +2 -0
- package/dist/distribution/types.js.map +1 -0
- package/dist/evidence/ChainEvidenceApi.d.ts +15 -0
- package/dist/evidence/ChainEvidenceApi.d.ts.map +1 -0
- package/dist/evidence/ChainEvidenceApi.js +22 -0
- package/dist/evidence/ChainEvidenceApi.js.map +1 -0
- package/dist/evidence/types.d.ts +15 -0
- package/dist/evidence/types.d.ts.map +1 -0
- package/dist/evidence/types.js +2 -0
- package/dist/evidence/types.js.map +1 -0
- package/dist/feegrant/ChainFeegrantApi.d.ts +22 -0
- package/dist/feegrant/ChainFeegrantApi.d.ts.map +1 -0
- package/dist/feegrant/ChainFeegrantApi.js +32 -0
- package/dist/feegrant/ChainFeegrantApi.js.map +1 -0
- package/dist/feegrant/types.d.ts +17 -0
- package/dist/feegrant/types.d.ts.map +1 -0
- package/dist/feegrant/types.js +2 -0
- package/dist/feegrant/types.js.map +1 -0
- package/dist/ibc/ChainIbcApi.d.ts +55 -0
- package/dist/ibc/ChainIbcApi.d.ts.map +1 -0
- package/dist/ibc/ChainIbcApi.js +82 -0
- package/dist/ibc/ChainIbcApi.js.map +1 -0
- package/dist/ibc/ibcChannel/ChainIbcChannelApi.d.ts +55 -0
- package/dist/ibc/ibcChannel/ChainIbcChannelApi.d.ts.map +1 -0
- package/dist/ibc/ibcChannel/ChainIbcChannelApi.js +82 -0
- package/dist/ibc/ibcChannel/ChainIbcChannelApi.js.map +1 -0
- package/dist/ibc/ibcChannel/types.d.ts +106 -0
- package/dist/ibc/ibcChannel/types.d.ts.map +1 -0
- package/dist/ibc/ibcChannel/types.js +2 -0
- package/dist/ibc/ibcChannel/types.js.map +1 -0
- package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.d.ts +14 -0
- package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.d.ts.map +1 -0
- package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.js +38 -0
- package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.js.map +1 -0
- package/dist/ibc/ibcChannelV2/types.d.ts +26 -0
- package/dist/ibc/ibcChannelV2/types.d.ts.map +1 -0
- package/dist/ibc/ibcChannelV2/types.js +3 -0
- package/dist/ibc/ibcChannelV2/types.js.map +1 -0
- package/dist/ibc/ibcClient/ChainIbcClientApi.d.ts +15 -0
- package/dist/ibc/ibcClient/ChainIbcClientApi.d.ts.map +1 -0
- package/dist/ibc/ibcClient/ChainIbcClientApi.js +39 -0
- package/dist/ibc/ibcClient/ChainIbcClientApi.js.map +1 -0
- package/dist/ibc/ibcClient/types.d.ts +53 -0
- package/dist/ibc/ibcClient/types.d.ts.map +1 -0
- package/dist/ibc/ibcClient/types.js +2 -0
- package/dist/ibc/ibcClient/types.js.map +1 -0
- package/dist/ibc/ibcConnection/ChainIbcConnectionApi.d.ts +11 -0
- package/dist/ibc/ibcConnection/ChainIbcConnectionApi.d.ts.map +1 -0
- package/dist/ibc/ibcConnection/ChainIbcConnectionApi.js +24 -0
- package/dist/ibc/ibcConnection/ChainIbcConnectionApi.js.map +1 -0
- package/dist/ibc/ibcConnection/types.d.ts +18 -0
- package/dist/ibc/ibcConnection/types.d.ts.map +1 -0
- package/dist/ibc/ibcConnection/types.js +2 -0
- package/dist/ibc/ibcConnection/types.js.map +1 -0
- package/dist/ibc/types.d.ts +106 -0
- package/dist/ibc/types.d.ts.map +1 -0
- package/dist/ibc/types.js +2 -0
- package/dist/ibc/types.js.map +1 -0
- package/dist/ibc-transfer/ChainIbcTransferApi.d.ts +12 -0
- package/dist/ibc-transfer/ChainIbcTransferApi.d.ts.map +1 -0
- package/dist/ibc-transfer/ChainIbcTransferApi.js +30 -0
- package/dist/ibc-transfer/ChainIbcTransferApi.js.map +1 -0
- package/dist/ibc-transfer/types.d.ts +26 -0
- package/dist/ibc-transfer/types.d.ts.map +1 -0
- package/dist/ibc-transfer/types.js +2 -0
- package/dist/ibc-transfer/types.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/dist/interchain-accounts/ChainInterChainAccApi.d.ts +9 -0
- package/dist/interchain-accounts/ChainInterChainAccApi.d.ts.map +1 -0
- package/dist/interchain-accounts/ChainInterChainAccApi.js +16 -0
- package/dist/interchain-accounts/ChainInterChainAccApi.js.map +1 -0
- package/dist/interchain-accounts/types.d.ts +12 -0
- package/dist/interchain-accounts/types.d.ts.map +1 -0
- package/dist/interchain-accounts/types.js +2 -0
- package/dist/interchain-accounts/types.js.map +1 -0
- package/dist/networks/endpoints.js +2 -2
- package/dist/networks/endpoints.js.map +1 -1
- package/dist/runtime/ChainRuntimeApi.d.ts +12 -0
- package/dist/runtime/ChainRuntimeApi.d.ts.map +1 -0
- package/dist/runtime/ChainRuntimeApi.js +16 -0
- package/dist/runtime/ChainRuntimeApi.js.map +1 -0
- package/dist/runtime/types.d.ts +4 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +2 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/tokenwrapper/ChainTokenWrapperApi.d.ts +19 -0
- package/dist/tokenwrapper/ChainTokenWrapperApi.d.ts.map +1 -0
- package/dist/tokenwrapper/ChainTokenWrapperApi.js +26 -0
- package/dist/tokenwrapper/ChainTokenWrapperApi.js.map +1 -0
- package/dist/tokenwrapper/types.d.ts +15 -0
- package/dist/tokenwrapper/types.d.ts.map +1 -0
- package/dist/tokenwrapper/types.js +2 -0
- package/dist/tokenwrapper/types.js.map +1 -0
- package/dist/txs/ChainTxsApi.d.ts +12 -0
- package/dist/txs/ChainTxsApi.d.ts.map +1 -0
- package/dist/txs/ChainTxsApi.js +17 -0
- package/dist/txs/ChainTxsApi.js.map +1 -0
- package/dist/txs/types.d.ts +22 -0
- package/dist/txs/types.d.ts.map +1 -0
- package/dist/txs/types.js +5 -0
- package/dist/txs/types.js.map +1 -0
- package/dist/upgrade/ChainUpgradeApi.d.ts +22 -0
- package/dist/upgrade/ChainUpgradeApi.d.ts.map +1 -0
- package/dist/upgrade/ChainUpgradeApi.js +40 -0
- package/dist/upgrade/ChainUpgradeApi.js.map +1 -0
- package/dist/upgrade/types.d.ts +24 -0
- package/dist/upgrade/types.d.ts.map +1 -0
- package/dist/upgrade/types.js +5 -0
- package/dist/upgrade/types.js.map +1 -0
- package/dist/validator-set/ChainCometValidator.d.ts +8 -0
- package/dist/validator-set/ChainCometValidator.d.ts.map +1 -0
- package/dist/validator-set/ChainCometValidator.js +15 -0
- package/dist/validator-set/ChainCometValidator.js.map +1 -0
- package/dist/validator-set/types.d.ts +18 -0
- package/dist/validator-set/types.d.ts.map +1 -0
- package/dist/validator-set/types.js +2 -0
- package/dist/validator-set/types.js.map +1 -0
- package/dist/wasm/ChainWasmApi.d.ts +57 -0
- package/dist/wasm/ChainWasmApi.d.ts.map +1 -0
- package/dist/wasm/ChainWasmApi.js +78 -0
- package/dist/wasm/ChainWasmApi.js.map +1 -0
- package/dist/wasm/types.d.ts +77 -0
- package/dist/wasm/types.d.ts.map +1 -0
- package/dist/wasm/types.js +2 -0
- package/dist/wasm/types.js.map +1 -0
- package/docs/auth.md +555 -0
- package/docs/bank.md +974 -0
- package/docs/block-results.md +371 -0
- package/docs/block.md +97 -0
- package/docs/circuit.md +93 -0
- package/docs/comet-validator-set.md +70 -0
- package/docs/dex.md +159 -0
- package/docs/distribution.md +201 -0
- package/docs/evidence.md +199 -0
- package/docs/factory.md +159 -0
- package/docs/feegrant.md +206 -0
- package/docs/gov.md +166 -0
- package/docs/ibc/ibcChannel.md +490 -0
- package/docs/ibc/ibcClient.md +302 -0
- package/docs/ibc/ibcConnection.md +214 -0
- package/docs/ibc-transfer.md +204 -0
- package/docs/interchain-accounts.md +120 -0
- package/docs/mint.md +133 -0
- package/docs/runtime.md +81 -0
- package/docs/slashing.md +139 -0
- package/docs/staking.md +633 -0
- package/docs/tokenwrapper.md +137 -0
- package/docs/txs.md +0 -0
- package/docs/upgrade.md +133 -0
- package/docs/wasm.md +916 -0
- package/package.json +2 -1
package/docs/auth.md
ADDED
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
# Auth Module
|
|
2
|
+
|
|
3
|
+
## What is the Auth Module?
|
|
4
|
+
|
|
5
|
+
The **Auth module** is a core Cosmos SDK module responsible for managing **accounts** on the blockchain.
|
|
6
|
+
|
|
7
|
+
In **ZigChain**, every address that holds tokens, signs transactions, or interacts with the chain is backed by an account managed by this module.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Important Terminology
|
|
12
|
+
|
|
13
|
+
### Account
|
|
14
|
+
|
|
15
|
+
An **Account** is an on-chain entity identified by a unique bech32 address. It tracks the public key, sequence number, and account number required to authorize transactions.
|
|
16
|
+
|
|
17
|
+
There are different account types:
|
|
18
|
+
|
|
19
|
+
| Type | Description |
|
|
20
|
+
| ------------- | ------------------------------------------------ |
|
|
21
|
+
| BaseAccount | Standard user account |
|
|
22
|
+
| ModuleAccount | System account owned by a chain module (e.g. staking, gov) |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
### Account Number
|
|
27
|
+
|
|
28
|
+
A unique numeric ID assigned to an account when it is first seen on-chain.
|
|
29
|
+
|
|
30
|
+
Example:
|
|
31
|
+
```
|
|
32
|
+
account_number = 138553
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### Sequence
|
|
38
|
+
|
|
39
|
+
A counter that increments with every transaction signed by an account. Used to prevent replay attacks.
|
|
40
|
+
|
|
41
|
+
Example:
|
|
42
|
+
```
|
|
43
|
+
sequence = 115309
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
> Both `account_number` and `sequence` are **required** when building and signing transactions.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
### Public Key
|
|
51
|
+
|
|
52
|
+
The cryptographic public key associated with an account. Used to verify transaction signatures.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### Bech32 Prefix
|
|
57
|
+
|
|
58
|
+
The human-readable prefix prepended to all addresses on a chain. ZigChain uses `zig` as its prefix.
|
|
59
|
+
|
|
60
|
+
Example:
|
|
61
|
+
```
|
|
62
|
+
zig1svkn4sqrlz8r6krq96ty6kze54n2ec03u0vat5
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Setup
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import {
|
|
71
|
+
ChainAuthApi,
|
|
72
|
+
getNetworkEndpoints,
|
|
73
|
+
Network,
|
|
74
|
+
} from '@zuhaibnoor/zigchain-sdk'
|
|
75
|
+
|
|
76
|
+
const endpoints = getNetworkEndpoints(Network.Testnet)
|
|
77
|
+
const authApi = new ChainAuthApi(endpoints)
|
|
78
|
+
|
|
79
|
+
const address = 'zig1svkn4sqrlz8r6krq96ty6kze54n2ec03u0vat5'
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
# 1️⃣ fetchAccount
|
|
85
|
+
|
|
86
|
+
## Method
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
async fetchAccount(address: string)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## CLI Equivalent
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
zigchaind query auth account <address>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Description
|
|
99
|
+
|
|
100
|
+
Fetches the **full account object** for a given address.
|
|
101
|
+
|
|
102
|
+
This returns the complete account representation, which varies depending on account type. For a standard user wallet this will be a `BaseAccount`. For chain-owned system addresses it may be a `ModuleAccount`.
|
|
103
|
+
|
|
104
|
+
This is the most complete account query available.
|
|
105
|
+
|
|
106
|
+
## Parameters
|
|
107
|
+
|
|
108
|
+
| Name | Type | Description |
|
|
109
|
+
| ------- | ------ | ---------------------------------- |
|
|
110
|
+
| address | string | Bech32 address of the account to query |
|
|
111
|
+
|
|
112
|
+
## Usage Example
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
const account = await authApi.fetchAccount(address)
|
|
116
|
+
console.dir(account, { depth: null })
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Example Response
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"account": {
|
|
124
|
+
"@type": "/cosmos.auth.v1beta1.BaseAccount",
|
|
125
|
+
"address": "zig1svkn4sqrlz8r6krq96ty6kze54n2ec03u0vat5",
|
|
126
|
+
"pub_key": {
|
|
127
|
+
"@type": "/cosmos.crypto.secp256k1.PubKey",
|
|
128
|
+
"key": "Ax6bvKIvU8eViWA6rmn6c/fyYiyuj3/tyiJt2gzv/UDP"
|
|
129
|
+
},
|
|
130
|
+
"account_number": "138553",
|
|
131
|
+
"sequence": "115309"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Response Field Explanation
|
|
137
|
+
|
|
138
|
+
### `account`
|
|
139
|
+
|
|
140
|
+
The full account object.
|
|
141
|
+
|
|
142
|
+
| Field | Description |
|
|
143
|
+
| -------------- | ---------------------------------------------------------- |
|
|
144
|
+
| @type | Protobuf type URL indicating the account type |
|
|
145
|
+
| address | Bech32 address of the account |
|
|
146
|
+
| pub_key.@type | Cryptographic key type (secp256k1 for standard accounts) |
|
|
147
|
+
| pub_key.key | Base64-encoded public key |
|
|
148
|
+
| account_number | Unique chain-assigned ID for this account |
|
|
149
|
+
| sequence | Number of transactions sent — increments with each tx |
|
|
150
|
+
|
|
151
|
+
> ⚠️ `pub_key` may be `null` if the account exists on-chain but has never signed a transaction.
|
|
152
|
+
|
|
153
|
+
## When to Use
|
|
154
|
+
|
|
155
|
+
* Inspecting the full account object and type
|
|
156
|
+
* Checking account type (`BaseAccount` vs `ModuleAccount`)
|
|
157
|
+
* Block explorers displaying full account details
|
|
158
|
+
* Debugging account state
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
# 2️⃣ fetchAccountInfo
|
|
163
|
+
|
|
164
|
+
## Method
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
async fetchAccountInfo(address: string)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## CLI Equivalent
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
zigchaind query auth account-info <address>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Description
|
|
177
|
+
|
|
178
|
+
Fetches **lightweight account info** — only the fields required for **signing transactions**.
|
|
179
|
+
|
|
180
|
+
Unlike `fetchAccount`, this endpoint returns a consistent, type-agnostic response regardless of the underlying account type. This makes it the preferred query when building and signing transactions.
|
|
181
|
+
|
|
182
|
+
Returns: address, public key, account number, and sequence.
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
## Parameters
|
|
186
|
+
|
|
187
|
+
| Name | Type | Description |
|
|
188
|
+
| ------- | ------ | -------------------------------------- |
|
|
189
|
+
| address | string | Bech32 address of the account to query |
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
## Usage Example
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
const info = await authApi.fetchAccountInfo(address)
|
|
196
|
+
console.dir(info, { depth: null })
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Example Response
|
|
200
|
+
|
|
201
|
+
```json
|
|
202
|
+
{
|
|
203
|
+
"info": {
|
|
204
|
+
"address": "zig1svkn4sqrlz8r6krq96ty6kze54n2ec03u0vat5",
|
|
205
|
+
"pub_key": {
|
|
206
|
+
"@type": "/cosmos.crypto.secp256k1.PubKey",
|
|
207
|
+
"key": "Ax6bvKIvU8eViWA6rmn6c/fyYiyuj3/tyiJt2gzv/UDP"
|
|
208
|
+
},
|
|
209
|
+
"account_number": "138553",
|
|
210
|
+
"sequence": "115309"
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Response Field Explanation
|
|
216
|
+
|
|
217
|
+
### `info`
|
|
218
|
+
|
|
219
|
+
| Field | Description |
|
|
220
|
+
| -------------- | ----------------------------------------------------- |
|
|
221
|
+
| address | Bech32 address of the account |
|
|
222
|
+
| pub_key.@type | Cryptographic key type |
|
|
223
|
+
| pub_key.key | Base64-encoded public key |
|
|
224
|
+
| account_number | Required for tx signing — unique ID for this account |
|
|
225
|
+
| sequence | Required for tx signing — increments with each tx |
|
|
226
|
+
|
|
227
|
+
### `fetchAccountInfo` vs `fetchAccount`
|
|
228
|
+
|
|
229
|
+
| Feature | fetchAccount | fetchAccountInfo |
|
|
230
|
+
| -------------------- | -------------------- | ---------------------- |
|
|
231
|
+
| Returns account type | ✅ Yes | ❌ No |
|
|
232
|
+
| Ideal for tx signing | ⚠️ Works but verbose | ✅ Preferred |
|
|
233
|
+
| Response size | Larger | Minimal |
|
|
234
|
+
|
|
235
|
+
## When to Use
|
|
236
|
+
|
|
237
|
+
* Building and signing transactions (primary use case)
|
|
238
|
+
* Fetching `account_number` and `sequence` for tx construction
|
|
239
|
+
* Wallet implementations
|
|
240
|
+
* Any scenario where only signing data is needed
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
# 3️⃣ fetchBech32Prefix
|
|
245
|
+
|
|
246
|
+
## Method
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
async fetchBech32Prefix()
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## CLI Equivalent
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
zigchaind query auth bech32-prefix
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Description
|
|
259
|
+
|
|
260
|
+
Fetches the **Bech32 address prefix** configured for the chain.
|
|
261
|
+
|
|
262
|
+
This prefix is prepended to all addresses on the network. For ZigChain, this will always be `zig`.
|
|
263
|
+
|
|
264
|
+
This is useful when you need to programmatically verify that an address belongs to ZigChain, or when building tools that support multiple chains.
|
|
265
|
+
|
|
266
|
+
## Parameters
|
|
267
|
+
|
|
268
|
+
None.
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
## Usage Example
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
const prefix = await authApi.fetchBech32Prefix()
|
|
275
|
+
console.dir(prefix, { depth: null })
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Example Response
|
|
279
|
+
|
|
280
|
+
```json
|
|
281
|
+
{
|
|
282
|
+
"bech32_prefix": "zig"
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Response Field Explanation
|
|
287
|
+
|
|
288
|
+
| Field | Description |
|
|
289
|
+
| ------------- | ---------------------------------------- |
|
|
290
|
+
| bech32_prefix | The human-readable prefix for addresses on this chain |
|
|
291
|
+
|
|
292
|
+
## When to Use
|
|
293
|
+
|
|
294
|
+
* Validating that an address belongs to ZigChain
|
|
295
|
+
* Multi-chain tools that need to identify the network
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
# 4️⃣ fetchModuleAccounts
|
|
300
|
+
|
|
301
|
+
## Method
|
|
302
|
+
|
|
303
|
+
```ts
|
|
304
|
+
async fetchModuleAccounts()
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## CLI Equivalent
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
zigchaind query auth module-accounts
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Description
|
|
314
|
+
|
|
315
|
+
Fetches **all module accounts** registered on the chain.
|
|
316
|
+
|
|
317
|
+
Module accounts are special system-owned accounts that belong to chain modules (e.g. `gov`, `staking`, `mint`). Unlike user accounts, they are not controlled by a private key — they are controlled programmatically by their respective modules.
|
|
318
|
+
|
|
319
|
+
Each module account has a set of **permissions** that define what it is allowed to do with tokens.
|
|
320
|
+
|
|
321
|
+
## Parameters
|
|
322
|
+
|
|
323
|
+
None.
|
|
324
|
+
|
|
325
|
+
## Usage Example
|
|
326
|
+
|
|
327
|
+
```ts
|
|
328
|
+
const modAccounts = await authApi.fetchModuleAccounts()
|
|
329
|
+
console.dir(modAccounts, { depth: null })
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
## Example Response
|
|
333
|
+
|
|
334
|
+
```json
|
|
335
|
+
{
|
|
336
|
+
"accounts": [
|
|
337
|
+
{
|
|
338
|
+
"@type": "/cosmos.auth.v1beta1.ModuleAccount",
|
|
339
|
+
"base_account": {
|
|
340
|
+
"address": "zig1fl48vsnmsdzcv85q5d2q4z5ajdha8yu353vaml",
|
|
341
|
+
"pub_key": null,
|
|
342
|
+
"account_number": "17",
|
|
343
|
+
"sequence": "0"
|
|
344
|
+
},
|
|
345
|
+
"name": "bonded_tokens_pool",
|
|
346
|
+
"permissions": ["burner", "staking"]
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
"@type": "/cosmos.auth.v1beta1.ModuleAccount",
|
|
350
|
+
"base_account": {
|
|
351
|
+
"address": "zig10d07y265gmmuvt4z0w9aw880jnsr700jmgkh5m",
|
|
352
|
+
"pub_key": null,
|
|
353
|
+
"account_number": "19",
|
|
354
|
+
"sequence": "0"
|
|
355
|
+
},
|
|
356
|
+
"name": "gov",
|
|
357
|
+
"permissions": ["burner"]
|
|
358
|
+
}
|
|
359
|
+
]
|
|
360
|
+
}
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
## Response Field Explanation
|
|
364
|
+
|
|
365
|
+
### `accounts`
|
|
366
|
+
|
|
367
|
+
Array of all module accounts on the chain.
|
|
368
|
+
|
|
369
|
+
Each entry contains:
|
|
370
|
+
|
|
371
|
+
| Field | Description |
|
|
372
|
+
| --------------------------- | -------------------------------------------------------- |
|
|
373
|
+
| @type | Always `/cosmos.auth.v1beta1.ModuleAccount` |
|
|
374
|
+
| base_account.address | Bech32 address of the module account |
|
|
375
|
+
| base_account.pub_key | Always `null` — module accounts have no private key |
|
|
376
|
+
| base_account.account_number | Chain-assigned account ID |
|
|
377
|
+
| base_account.sequence | Always `0` — module accounts never sign transactions |
|
|
378
|
+
| name | Unique identifier for the module (e.g. `gov`, `staking`) |
|
|
379
|
+
| permissions | List of token operation permissions granted to this module |
|
|
380
|
+
|
|
381
|
+
### Module Permission Types
|
|
382
|
+
|
|
383
|
+
| Permission | Meaning |
|
|
384
|
+
| ---------- | ------------------------------------------------ |
|
|
385
|
+
| minter | Can mint (create) new tokens |
|
|
386
|
+
| burner | Can burn (destroy) tokens |
|
|
387
|
+
| staking | Can interact with staked/bonded token operations |
|
|
388
|
+
|
|
389
|
+
## When to Use
|
|
390
|
+
|
|
391
|
+
* Inspecting all system accounts on the chain
|
|
392
|
+
* Understanding which modules have minting or burning capabilities
|
|
393
|
+
* Block explorer chain overview pages
|
|
394
|
+
* Security auditing of module permissions
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
# 5️⃣ fetchAccountsByModule
|
|
399
|
+
|
|
400
|
+
## Method
|
|
401
|
+
|
|
402
|
+
```ts
|
|
403
|
+
async fetchAccountsByModule(moduleName: string)
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
## CLI Equivalent
|
|
407
|
+
|
|
408
|
+
```bash
|
|
409
|
+
zigchaind query auth module-account <module_name>
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
## Description
|
|
413
|
+
|
|
414
|
+
Fetches the **module account details** for a single, specific module by name.
|
|
415
|
+
|
|
416
|
+
Use this when you need the address, account number, or permissions of one particular module rather than fetching all of them with `fetchModuleAccounts`.
|
|
417
|
+
|
|
418
|
+
## Parameters
|
|
419
|
+
|
|
420
|
+
| Name | Type | Description |
|
|
421
|
+
| ---------- | ------ | -------------------------------------------------------------- |
|
|
422
|
+
| moduleName | string | Name of the module (e.g. `gov`, `staking` etc) |
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
## Usage Example
|
|
426
|
+
|
|
427
|
+
```ts
|
|
428
|
+
const govModule = await authApi.fetchAccountsByModule('gov')
|
|
429
|
+
console.dir(govModule, { depth: null })
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
## Example Response
|
|
433
|
+
|
|
434
|
+
```json
|
|
435
|
+
{
|
|
436
|
+
"account": {
|
|
437
|
+
"@type": "/cosmos.auth.v1beta1.ModuleAccount",
|
|
438
|
+
"base_account": {
|
|
439
|
+
"address": "zig10d07y265gmmuvt4z0w9aw880jnsr700jmgkh5m",
|
|
440
|
+
"pub_key": null,
|
|
441
|
+
"account_number": "19",
|
|
442
|
+
"sequence": "0"
|
|
443
|
+
},
|
|
444
|
+
"name": "gov",
|
|
445
|
+
"permissions": ["burner"]
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
## Response Field Explanation
|
|
451
|
+
|
|
452
|
+
### `account`
|
|
453
|
+
|
|
454
|
+
| Field | Description |
|
|
455
|
+
| --------------------------- | -------------------------------------------------- |
|
|
456
|
+
| @type | Always `/cosmos.auth.v1beta1.ModuleAccount` |
|
|
457
|
+
| base_account.address | Bech32 address of this module account |
|
|
458
|
+
| base_account.pub_key | Always `null` — no private key for module accounts |
|
|
459
|
+
| base_account.account_number | Chain-assigned ID for this account |
|
|
460
|
+
| base_account.sequence | Always `0` |
|
|
461
|
+
| name | The module name as registered on-chain |
|
|
462
|
+
| permissions | Token operation permissions for this module |
|
|
463
|
+
|
|
464
|
+
## When to Use
|
|
465
|
+
|
|
466
|
+
* Checking permissions of a particular module
|
|
467
|
+
* Verifying module account existence
|
|
468
|
+
* Building tools that interact with module-controlled addresses (e.g. tracking gov deposit pool balances)
|
|
469
|
+
|
|
470
|
+
---
|
|
471
|
+
|
|
472
|
+
# 6️⃣ fetchAuthParams
|
|
473
|
+
|
|
474
|
+
## Method
|
|
475
|
+
|
|
476
|
+
```ts
|
|
477
|
+
async fetchAuthParams(height?: number)
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
## CLI Equivalent
|
|
481
|
+
|
|
482
|
+
```bash
|
|
483
|
+
zigchaind query auth params
|
|
484
|
+
zigchaind query auth params --height <H>
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
## Description
|
|
488
|
+
|
|
489
|
+
Fetches the **Auth module parameters** configured at chain level.
|
|
490
|
+
|
|
491
|
+
These parameters govern transaction validation rules — such as how large a memo can be, how many signatures a transaction can carry, and the computational cost of signature verification.
|
|
492
|
+
|
|
493
|
+
These are governance-controlled settings and can be updated via on-chain proposals.
|
|
494
|
+
|
|
495
|
+
Supports querying parameters at a **specific block height** for historical state.
|
|
496
|
+
|
|
497
|
+
## Parameters
|
|
498
|
+
|
|
499
|
+
| Name | Type | Required | Description |
|
|
500
|
+
| ------ | ------ | -------- | ----------------------------------------------------------------- |
|
|
501
|
+
| height | number | ❌ No | Block height to query at. Omit for latest state. |
|
|
502
|
+
|
|
503
|
+
## Usage Example
|
|
504
|
+
|
|
505
|
+
**Latest state:**
|
|
506
|
+
|
|
507
|
+
```ts
|
|
508
|
+
const params = await authApi.fetchAuthParams()
|
|
509
|
+
console.dir(params, { depth: null })
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
**Historical state at a specific block height:**
|
|
513
|
+
|
|
514
|
+
```ts
|
|
515
|
+
const paramsAtHeight = await authApi.fetchAuthParams(500000)
|
|
516
|
+
console.dir(paramsAtHeight, { depth: null })
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
## Example Response
|
|
520
|
+
|
|
521
|
+
```json
|
|
522
|
+
{
|
|
523
|
+
"params": {
|
|
524
|
+
"max_memo_characters": "256",
|
|
525
|
+
"tx_sig_limit": "7",
|
|
526
|
+
"tx_size_cost_per_byte": "10",
|
|
527
|
+
"sig_verify_cost_ed25519": "590",
|
|
528
|
+
"sig_verify_cost_secp256k1": "1000"
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
## Response Field Explanation
|
|
534
|
+
|
|
535
|
+
### `params`
|
|
536
|
+
|
|
537
|
+
| Field | Description |
|
|
538
|
+
| ------------------------ | ------------------------------------------------------------------------ |
|
|
539
|
+
| max_memo_characters | Maximum number of characters allowed in a transaction memo |
|
|
540
|
+
| tx_sig_limit | Maximum number of signatures allowed per transaction |
|
|
541
|
+
| tx_size_cost_per_byte | Gas cost charged per byte of transaction size |
|
|
542
|
+
| sig_verify_cost_ed25519 | Gas cost for verifying an Ed25519 signature |
|
|
543
|
+
| sig_verify_cost_secp256k1 | Gas cost for verifying a secp256k1 signature (standard user transactions) |
|
|
544
|
+
|
|
545
|
+
> On ZigChain, most user transactions use `secp256k1` signatures, so `sig_verify_cost_secp256k1` is the most commonly applied verification cost.
|
|
546
|
+
|
|
547
|
+
## When to Use
|
|
548
|
+
|
|
549
|
+
* Validating memo length before broadcasting a transaction
|
|
550
|
+
* Estimating gas costs for multi-signature transactions
|
|
551
|
+
* Auditing chain governance parameters
|
|
552
|
+
* Building chain configuration dashboards
|
|
553
|
+
|
|
554
|
+
---
|
|
555
|
+
|