@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.
Files changed (172) hide show
  1. package/dist/auth/ChainAuthApi.d.ts +0 -3
  2. package/dist/auth/ChainAuthApi.d.ts.map +1 -1
  3. package/dist/auth/ChainAuthApi.js +0 -26
  4. package/dist/auth/ChainAuthApi.js.map +1 -1
  5. package/dist/bank/ChainBankApi.d.ts +0 -9
  6. package/dist/bank/ChainBankApi.d.ts.map +1 -1
  7. package/dist/bank/ChainBankApi.js +0 -18
  8. package/dist/bank/ChainBankApi.js.map +1 -1
  9. package/dist/client/http.d.ts +1 -0
  10. package/dist/client/http.d.ts.map +1 -1
  11. package/dist/client/http.js +10 -0
  12. package/dist/client/http.js.map +1 -1
  13. package/dist/distribution/ChainDistributionApi.d.ts +47 -0
  14. package/dist/distribution/ChainDistributionApi.d.ts.map +1 -0
  15. package/dist/distribution/ChainDistributionApi.js +75 -0
  16. package/dist/distribution/ChainDistributionApi.js.map +1 -0
  17. package/dist/distribution/types.d.ts +71 -0
  18. package/dist/distribution/types.d.ts.map +1 -0
  19. package/dist/distribution/types.js +2 -0
  20. package/dist/distribution/types.js.map +1 -0
  21. package/dist/evidence/ChainEvidenceApi.d.ts +15 -0
  22. package/dist/evidence/ChainEvidenceApi.d.ts.map +1 -0
  23. package/dist/evidence/ChainEvidenceApi.js +22 -0
  24. package/dist/evidence/ChainEvidenceApi.js.map +1 -0
  25. package/dist/evidence/types.d.ts +15 -0
  26. package/dist/evidence/types.d.ts.map +1 -0
  27. package/dist/evidence/types.js +2 -0
  28. package/dist/evidence/types.js.map +1 -0
  29. package/dist/feegrant/ChainFeegrantApi.d.ts +22 -0
  30. package/dist/feegrant/ChainFeegrantApi.d.ts.map +1 -0
  31. package/dist/feegrant/ChainFeegrantApi.js +32 -0
  32. package/dist/feegrant/ChainFeegrantApi.js.map +1 -0
  33. package/dist/feegrant/types.d.ts +17 -0
  34. package/dist/feegrant/types.d.ts.map +1 -0
  35. package/dist/feegrant/types.js +2 -0
  36. package/dist/feegrant/types.js.map +1 -0
  37. package/dist/ibc/ChainIbcApi.d.ts +55 -0
  38. package/dist/ibc/ChainIbcApi.d.ts.map +1 -0
  39. package/dist/ibc/ChainIbcApi.js +82 -0
  40. package/dist/ibc/ChainIbcApi.js.map +1 -0
  41. package/dist/ibc/ibcChannel/ChainIbcChannelApi.d.ts +55 -0
  42. package/dist/ibc/ibcChannel/ChainIbcChannelApi.d.ts.map +1 -0
  43. package/dist/ibc/ibcChannel/ChainIbcChannelApi.js +82 -0
  44. package/dist/ibc/ibcChannel/ChainIbcChannelApi.js.map +1 -0
  45. package/dist/ibc/ibcChannel/types.d.ts +106 -0
  46. package/dist/ibc/ibcChannel/types.d.ts.map +1 -0
  47. package/dist/ibc/ibcChannel/types.js +2 -0
  48. package/dist/ibc/ibcChannel/types.js.map +1 -0
  49. package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.d.ts +14 -0
  50. package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.d.ts.map +1 -0
  51. package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.js +38 -0
  52. package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.js.map +1 -0
  53. package/dist/ibc/ibcChannelV2/types.d.ts +26 -0
  54. package/dist/ibc/ibcChannelV2/types.d.ts.map +1 -0
  55. package/dist/ibc/ibcChannelV2/types.js +3 -0
  56. package/dist/ibc/ibcChannelV2/types.js.map +1 -0
  57. package/dist/ibc/ibcClient/ChainIbcClientApi.d.ts +15 -0
  58. package/dist/ibc/ibcClient/ChainIbcClientApi.d.ts.map +1 -0
  59. package/dist/ibc/ibcClient/ChainIbcClientApi.js +39 -0
  60. package/dist/ibc/ibcClient/ChainIbcClientApi.js.map +1 -0
  61. package/dist/ibc/ibcClient/types.d.ts +53 -0
  62. package/dist/ibc/ibcClient/types.d.ts.map +1 -0
  63. package/dist/ibc/ibcClient/types.js +2 -0
  64. package/dist/ibc/ibcClient/types.js.map +1 -0
  65. package/dist/ibc/ibcConnection/ChainIbcConnectionApi.d.ts +11 -0
  66. package/dist/ibc/ibcConnection/ChainIbcConnectionApi.d.ts.map +1 -0
  67. package/dist/ibc/ibcConnection/ChainIbcConnectionApi.js +24 -0
  68. package/dist/ibc/ibcConnection/ChainIbcConnectionApi.js.map +1 -0
  69. package/dist/ibc/ibcConnection/types.d.ts +18 -0
  70. package/dist/ibc/ibcConnection/types.d.ts.map +1 -0
  71. package/dist/ibc/ibcConnection/types.js +2 -0
  72. package/dist/ibc/ibcConnection/types.js.map +1 -0
  73. package/dist/ibc/types.d.ts +106 -0
  74. package/dist/ibc/types.d.ts.map +1 -0
  75. package/dist/ibc/types.js +2 -0
  76. package/dist/ibc/types.js.map +1 -0
  77. package/dist/ibc-transfer/ChainIbcTransferApi.d.ts +12 -0
  78. package/dist/ibc-transfer/ChainIbcTransferApi.d.ts.map +1 -0
  79. package/dist/ibc-transfer/ChainIbcTransferApi.js +30 -0
  80. package/dist/ibc-transfer/ChainIbcTransferApi.js.map +1 -0
  81. package/dist/ibc-transfer/types.d.ts +26 -0
  82. package/dist/ibc-transfer/types.d.ts.map +1 -0
  83. package/dist/ibc-transfer/types.js +2 -0
  84. package/dist/ibc-transfer/types.js.map +1 -0
  85. package/dist/index.d.ts +26 -0
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +26 -0
  88. package/dist/index.js.map +1 -1
  89. package/dist/interchain-accounts/ChainInterChainAccApi.d.ts +9 -0
  90. package/dist/interchain-accounts/ChainInterChainAccApi.d.ts.map +1 -0
  91. package/dist/interchain-accounts/ChainInterChainAccApi.js +16 -0
  92. package/dist/interchain-accounts/ChainInterChainAccApi.js.map +1 -0
  93. package/dist/interchain-accounts/types.d.ts +12 -0
  94. package/dist/interchain-accounts/types.d.ts.map +1 -0
  95. package/dist/interchain-accounts/types.js +2 -0
  96. package/dist/interchain-accounts/types.js.map +1 -0
  97. package/dist/networks/endpoints.js +2 -2
  98. package/dist/networks/endpoints.js.map +1 -1
  99. package/dist/runtime/ChainRuntimeApi.d.ts +12 -0
  100. package/dist/runtime/ChainRuntimeApi.d.ts.map +1 -0
  101. package/dist/runtime/ChainRuntimeApi.js +16 -0
  102. package/dist/runtime/ChainRuntimeApi.js.map +1 -0
  103. package/dist/runtime/types.d.ts +4 -0
  104. package/dist/runtime/types.d.ts.map +1 -0
  105. package/dist/runtime/types.js +2 -0
  106. package/dist/runtime/types.js.map +1 -0
  107. package/dist/tokenwrapper/ChainTokenWrapperApi.d.ts +19 -0
  108. package/dist/tokenwrapper/ChainTokenWrapperApi.d.ts.map +1 -0
  109. package/dist/tokenwrapper/ChainTokenWrapperApi.js +26 -0
  110. package/dist/tokenwrapper/ChainTokenWrapperApi.js.map +1 -0
  111. package/dist/tokenwrapper/types.d.ts +15 -0
  112. package/dist/tokenwrapper/types.d.ts.map +1 -0
  113. package/dist/tokenwrapper/types.js +2 -0
  114. package/dist/tokenwrapper/types.js.map +1 -0
  115. package/dist/txs/ChainTxsApi.d.ts +12 -0
  116. package/dist/txs/ChainTxsApi.d.ts.map +1 -0
  117. package/dist/txs/ChainTxsApi.js +17 -0
  118. package/dist/txs/ChainTxsApi.js.map +1 -0
  119. package/dist/txs/types.d.ts +22 -0
  120. package/dist/txs/types.d.ts.map +1 -0
  121. package/dist/txs/types.js +5 -0
  122. package/dist/txs/types.js.map +1 -0
  123. package/dist/upgrade/ChainUpgradeApi.d.ts +22 -0
  124. package/dist/upgrade/ChainUpgradeApi.d.ts.map +1 -0
  125. package/dist/upgrade/ChainUpgradeApi.js +40 -0
  126. package/dist/upgrade/ChainUpgradeApi.js.map +1 -0
  127. package/dist/upgrade/types.d.ts +24 -0
  128. package/dist/upgrade/types.d.ts.map +1 -0
  129. package/dist/upgrade/types.js +5 -0
  130. package/dist/upgrade/types.js.map +1 -0
  131. package/dist/validator-set/ChainCometValidator.d.ts +8 -0
  132. package/dist/validator-set/ChainCometValidator.d.ts.map +1 -0
  133. package/dist/validator-set/ChainCometValidator.js +15 -0
  134. package/dist/validator-set/ChainCometValidator.js.map +1 -0
  135. package/dist/validator-set/types.d.ts +18 -0
  136. package/dist/validator-set/types.d.ts.map +1 -0
  137. package/dist/validator-set/types.js +2 -0
  138. package/dist/validator-set/types.js.map +1 -0
  139. package/dist/wasm/ChainWasmApi.d.ts +57 -0
  140. package/dist/wasm/ChainWasmApi.d.ts.map +1 -0
  141. package/dist/wasm/ChainWasmApi.js +78 -0
  142. package/dist/wasm/ChainWasmApi.js.map +1 -0
  143. package/dist/wasm/types.d.ts +77 -0
  144. package/dist/wasm/types.d.ts.map +1 -0
  145. package/dist/wasm/types.js +2 -0
  146. package/dist/wasm/types.js.map +1 -0
  147. package/docs/auth.md +555 -0
  148. package/docs/bank.md +974 -0
  149. package/docs/block-results.md +371 -0
  150. package/docs/block.md +97 -0
  151. package/docs/circuit.md +93 -0
  152. package/docs/comet-validator-set.md +70 -0
  153. package/docs/dex.md +159 -0
  154. package/docs/distribution.md +201 -0
  155. package/docs/evidence.md +199 -0
  156. package/docs/factory.md +159 -0
  157. package/docs/feegrant.md +206 -0
  158. package/docs/gov.md +166 -0
  159. package/docs/ibc/ibcChannel.md +490 -0
  160. package/docs/ibc/ibcClient.md +302 -0
  161. package/docs/ibc/ibcConnection.md +214 -0
  162. package/docs/ibc-transfer.md +204 -0
  163. package/docs/interchain-accounts.md +120 -0
  164. package/docs/mint.md +133 -0
  165. package/docs/runtime.md +81 -0
  166. package/docs/slashing.md +139 -0
  167. package/docs/staking.md +633 -0
  168. package/docs/tokenwrapper.md +137 -0
  169. package/docs/txs.md +0 -0
  170. package/docs/upgrade.md +133 -0
  171. package/docs/wasm.md +916 -0
  172. package/package.json +2 -1
@@ -0,0 +1,371 @@
1
+ # Block Results
2
+
3
+ ## What are the Block Results?
4
+
5
+ The **Block Results** provides access to the **execution results of a specific block** on ZigChain.
6
+
7
+ While other modules query the current state of the chain (balances, accounts, validators), the Block Results module lets you look back at what actually *happened* in a given block — every transaction that was processed, every event emitted, and every state change that occurred.
8
+
9
+ > ⚠️ **Important:** This module uses the **RPC endpoint**, not the LCD endpoint used by all other modules. This is handled automatically by the SDK — no extra configuration is needed.
10
+
11
+ ---
12
+
13
+ ## Important Terminology
14
+
15
+ ### Block
16
+
17
+ A **block** is a unit of the blockchain containing an ordered set of transactions. Each block is identified by a unique sequential **height**.
18
+
19
+ ---
20
+
21
+ ### Block Height
22
+
23
+ The position of a block in the chain, starting from `1`. Every new block increments the height by `1`.
24
+
25
+ Example:
26
+ ```
27
+ height = 2990050
28
+ ```
29
+
30
+ ---
31
+
32
+ ### Transaction Result (`txs_results`)
33
+
34
+ The execution outcome of each transaction included in the block.
35
+
36
+ Each result includes:
37
+
38
+ - Whether the transaction **succeeded or failed** (`code`)
39
+ - **Gas** consumed vs requested
40
+ - **Events** emitted during execution
41
+ - An **error log** if the transaction failed
42
+
43
+ ---
44
+
45
+ ### Transaction Code
46
+
47
+ A numeric result code indicating transaction success or failure.
48
+
49
+ | Code | Meaning |
50
+ | ---- | ------- |
51
+ | `0` | Success — transaction executed without errors |
52
+ | Any non-zero | Failure — see `log` for the error message |
53
+
54
+ ---
55
+
56
+ ### Events
57
+
58
+ **Events** are structured log entries emitted during block and transaction execution. They are the primary way to track on-chain activity such as token transfers, contract executions, reward distributions, and fee payments.
59
+
60
+ Each event has a `type` and an array of `attributes` (key-value pairs).
61
+
62
+ ---
63
+
64
+ ### Common Event Types
65
+
66
+ | Event Type | Description |
67
+ | ------------------- | ---------------------------------------------------- |
68
+ | `coin_spent` | Tokens were debited from an address |
69
+ | `coin_received` | Tokens were credited to an address |
70
+ | `transfer` | A token transfer occurred between addresses |
71
+ | `message` | A message was processed (action, sender, etc.) |
72
+ | `tx` | Transaction-level metadata (fee, signature, acc_seq) |
73
+ | `execute` | A CosmWasm contract was executed |
74
+ | `wasm` | Events emitted from within a CosmWasm contract |
75
+ | `coinbase` | New tokens were minted |
76
+ | `mint` | Block-level inflation minting details |
77
+ | `commission` | Validator commission was distributed |
78
+ | `rewards` | Staking rewards were distributed to validators |
79
+ | `denom_minted_and_sent` | Factory module minted and transferred tokens |
80
+
81
+ ---
82
+
83
+ ### Finalize Block Events (`finalize_block_events`)
84
+
85
+ Events that occur at the **block level** rather than within individual transactions. These cover system-level operations that happen automatically each block, such as:
86
+
87
+ - Inflation minting
88
+ - Fee collection
89
+ - Staking reward and commission distribution to validators
90
+
91
+ ---
92
+
93
+ ### Gas
94
+
95
+ | Field | Description |
96
+ | ------------ | ------------------------------------------------------------ |
97
+ | `gas_wanted` | Maximum gas the transaction sender authorized |
98
+ | `gas_used` | Actual gas consumed during execution |
99
+
100
+ > If `gas_used` approaches `gas_wanted`, the transaction may have been close to running out of gas.
101
+
102
+ ---
103
+
104
+ ## Setup
105
+
106
+ ```ts
107
+ import {
108
+ ChainBlockResultsApi,
109
+ getNetworkEndpoints,
110
+ Network,
111
+ } from '@zuhaibnoor/zigchain-sdk'
112
+
113
+ const endpoints = getNetworkEndpoints(Network.Testnet)
114
+ const blockResultsApi = new ChainBlockResultsApi(endpoints)
115
+ ```
116
+
117
+ ---
118
+
119
+ # 1️⃣ fetchBlockResults
120
+
121
+ ## Method
122
+
123
+ ```ts
124
+ async fetchBlockResults(height: number)
125
+ ```
126
+
127
+ ## CLI Equivalent
128
+
129
+ ```bash
130
+ zigchaind query block-results <height>
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Description
136
+
137
+ Fetches the **full execution results for a specific block** by height.
138
+
139
+ This includes every transaction result processed in that block, all events emitted at the transaction level, all events emitted at the block level (finalize block events), validator updates, and consensus parameter updates.
140
+
141
+ This is the most detailed view available for what happened at a specific point in chain history.
142
+
143
+ > ⚠️ This function queries the **RPC endpoint** internally, unlike all other SDK modules which use the LCD endpoint.
144
+
145
+ ---
146
+
147
+ ## Parameters
148
+
149
+ | Name | Type | Required | Description |
150
+ | ------ | ------ | -------- | ---------------------------------- |
151
+ | height | number | ✅ Yes | Block height to fetch results for |
152
+
153
+ ---
154
+
155
+ ## Usage Example
156
+
157
+ ```ts
158
+ const results = await blockResultsApi.fetchBlockResults(2990050)
159
+ console.dir(results, { depth: null })
160
+ ```
161
+
162
+ ## Example Response
163
+
164
+ ```json
165
+ {
166
+ "jsonrpc": "2.0",
167
+ "id": -1,
168
+ "result": {
169
+ "height": "2990050",
170
+ "txs_results": [
171
+ {
172
+ "code": 0,
173
+ "data": "Ei4KLC9jb3Ntd2FzbS53YXNtLnYxLk1zZ0V4ZWN1dGVDb250cmFjdFJlc3BvbnNl",
174
+ "log": "",
175
+ "info": "",
176
+ "gas_wanted": "286320",
177
+ "gas_used": "245458",
178
+ "events": [
179
+ {
180
+ "type": "transfer",
181
+ "attributes": [
182
+ { "key": "recipient", "value": "zig17xpfvakm2amg962yls6f84z3kell8c5l3nxjf4", "index": true },
183
+ { "key": "sender", "value": "zig1eyrwj20cujzwrln2gztmxgfx2vkp0l6le3xf2z", "index": true },
184
+ { "key": "amount", "value": "8590uzig", "index": true }
185
+ ]
186
+ },
187
+ {
188
+ "type": "wasm",
189
+ "attributes": [
190
+ { "key": "_contract_address", "value": "zig15jqg0hmp9n06q0as7uk3x9xkwr9k3r7yh4ww2uc0hek8zlryrgmsamk4qg", "index": true },
191
+ { "key": "action", "value": "provide_liquidity", "index": true },
192
+ { "key": "share", "value": "285", "index": true }
193
+ ]
194
+ }
195
+ ],
196
+ "codespace": ""
197
+ },
198
+ {
199
+ "code": 5,
200
+ "data": null,
201
+ "log": "failed to execute message; message index: 0: Operation exceeds max spread limit: execute wasm contract failed",
202
+ "gas_wanted": "500000",
203
+ "gas_used": "212387",
204
+ "events": [...],
205
+ "codespace": "wasm"
206
+ }
207
+ ],
208
+ "finalize_block_events": [
209
+ {
210
+ "type": "mint",
211
+ "attributes": [
212
+ { "key": "bonded_ratio", "value": "0.043487338234004096", "index": true },
213
+ { "key": "inflation", "value": "0.013406523098689013", "index": true },
214
+ { "key": "annual_provisions", "value": "31088831973883.453729872137993930", "index": true },
215
+ { "key": "amount", "value": "2464550", "index": true }
216
+ ]
217
+ },
218
+ {
219
+ "type": "rewards",
220
+ "attributes": [
221
+ { "key": "amount", "value": "619572.861060342856543622uzig", "index": true },
222
+ { "key": "validator", "value": "zigvaloper1pwwymlyeyfcz3pjvcegvz8tj3yf0pr3wqqhrwk", "index": true }
223
+ ]
224
+ }
225
+ ],
226
+ "validator_updates": null,
227
+ "consensus_param_updates": {
228
+ "block": { "max_bytes": "5000000", "max_gas": "100000000" },
229
+ "evidence": {
230
+ "max_age_num_blocks": "100000",
231
+ "max_age_duration": "172800000000000",
232
+ "max_bytes": "1048576"
233
+ },
234
+ "validator": { "pub_key_types": ["ed25519"] }
235
+ },
236
+ "app_hash": "PPCXOVQT5jIl2vYJvYUjDbgYe36WtCVdzuNx3mmF+dk="
237
+ }
238
+ }
239
+ ```
240
+
241
+ ---
242
+
243
+ ## Response Field Explanation
244
+
245
+ ### Top-level wrapper
246
+
247
+ | Field | Description |
248
+ | ------- | ------------------------------------------------ |
249
+ | jsonrpc | JSON-RPC protocol version (always `"2.0"`) |
250
+ | id | Request ID (always `-1` for SDK queries) |
251
+ | result | The actual block results payload |
252
+
253
+ ---
254
+
255
+ ### `result`
256
+
257
+ | Field | Description |
258
+ | ------------------------ | -------------------------------------------------------------------- |
259
+ | height | Block height this result corresponds to |
260
+ | txs_results | Array of execution results, one per transaction in the block |
261
+ | finalize_block_events | Block-level events (inflation, rewards, commissions) |
262
+ | validator_updates | Any validator set changes applied at this block. `null` if none |
263
+ | consensus_param_updates | Consensus configuration active at this block |
264
+ | app_hash | Application state hash after this block was applied |
265
+
266
+ ---
267
+
268
+ ### `txs_results[]` — Per-Transaction Result
269
+
270
+ | Field | Description |
271
+ | ----------- | ------------------------------------------------------------------------ |
272
+ | code | `0` = success. Any non-zero = failure |
273
+ | data | Base64-encoded protobuf response from the message handler |
274
+ | log | Empty on success. Contains the error message on failure |
275
+ | info | Optional additional info string |
276
+ | gas_wanted | Gas limit set by the transaction sender |
277
+ | gas_used | Actual gas consumed during execution |
278
+ | events | Array of events emitted by this transaction |
279
+ | codespace | Module namespace for the error code. Empty on success |
280
+
281
+ ---
282
+
283
+ ### `events[]` — Event Structure
284
+
285
+ Each event (at both transaction and block level) follows this structure:
286
+
287
+ | Field | Description |
288
+ | ---------- | ---------------------------------------------------- |
289
+ | type | Event category (e.g. `transfer`, `wasm`, `mint`) |
290
+ | attributes | Array of key-value pairs describing the event detail |
291
+
292
+ Each attribute contains:
293
+
294
+ | Field | Description |
295
+ | ----- | ------------------------------------------------------ |
296
+ | key | Attribute name |
297
+ | value | Attribute value |
298
+ | index | Whether this attribute is indexed for event search |
299
+
300
+ ---
301
+
302
+ ### `finalize_block_events[]` — Block-Level Events
303
+
304
+ These events fire automatically each block regardless of transactions. Common block-level events and their attributes:
305
+
306
+ **`mint`** — Inflation tokens minted this block
307
+
308
+ | Attribute | Description |
309
+ | ------------------ | ---------------------------------------- |
310
+ | bonded_ratio | Fraction of supply currently staked |
311
+ | inflation | Current annual inflation rate |
312
+ | annual_provisions | Projected annual token emission |
313
+ | amount | Tokens minted this block (in `uzig`) |
314
+
315
+ **`commission`** — Validator commission distributed
316
+
317
+ | Attribute | Description |
318
+ | --------- | ----------------------------------- |
319
+ | amount | Commission amount paid |
320
+ | validator | Validator operator address |
321
+
322
+ **`rewards`** — Staking rewards distributed
323
+
324
+ | Attribute | Description |
325
+ | --------- | ------------------------------------- |
326
+ | amount | Total rewards distributed |
327
+ | validator | Validator operator address |
328
+
329
+ ---
330
+
331
+ ### `consensus_param_updates`
332
+
333
+ Active consensus configuration for this block.
334
+
335
+ | Field | Description |
336
+ | ------------------------------ | --------------------------------------------------- |
337
+ | block.max_bytes | Maximum block size in bytes |
338
+ | block.max_gas | Maximum gas allowed per block |
339
+ | evidence.max_age_num_blocks | How many blocks back evidence remains valid |
340
+ | evidence.max_age_duration | Time duration evidence remains valid (nanoseconds) |
341
+ | evidence.max_bytes | Maximum evidence size per block |
342
+ | validator.pub_key_types | Accepted validator key types (e.g. `ed25519`) |
343
+
344
+ ---
345
+
346
+ ## Reading a Failed Transaction
347
+
348
+ When `code` is non-zero, the `log` field contains the error reason and `codespace` identifies which module raised it:
349
+
350
+ ```json
351
+ {
352
+ "code": 5,
353
+ "log": "failed to execute message; message index: 0: Operation exceeds max spread limit: execute wasm contract failed",
354
+ "codespace": "wasm"
355
+ }
356
+ ```
357
+
358
+ > Even failed transactions consume gas and emit fee-related events (the fee is still charged).
359
+
360
+ ---
361
+
362
+ ## When to Use
363
+
364
+ * Indexing all on-chain activity for a given block
365
+ * Building block explorer transaction detail pages
366
+ * Tracking contract executions and their emitted events
367
+ * Monitoring validator reward and commission distribution
368
+ * Debugging failed transactions and identifying error reasons
369
+ * Auditing token flows within a specific block
370
+
371
+ ---
package/docs/block.md ADDED
@@ -0,0 +1,97 @@
1
+ # Block Info
2
+
3
+ The **ChainBlockApi** lets you query blockchain blocks and block data.
4
+ It is mainly used to fetch the latest block or retrieve a block at a specific height, including historical state queries.
5
+
6
+ ---
7
+
8
+ ## Setup
9
+
10
+ ```ts
11
+ import {
12
+ ChainBlockApi,
13
+ getNetworkEndpoints,
14
+ Network,
15
+ } from '@zuhaibnoor/zigchain-sdk'
16
+
17
+ const endpoints = getNetworkEndpoints(Network.Testnet)
18
+ const blockApi = new ChainBlockApi(endpoints)
19
+ ```
20
+
21
+ ---
22
+
23
+ ## `getLatestBlock`
24
+
25
+ Fetch the **latest committed block** on the chain.
26
+ You can also query how the latest block looked at a specific historical height.
27
+
28
+ **CLI equivalent**
29
+
30
+ ```bash
31
+ zigchaind query block
32
+ zigchaind query block --height <H>
33
+ ```
34
+
35
+ **Method**
36
+
37
+ ```ts
38
+ getLatestBlock(atHeight?: number)
39
+ ```
40
+
41
+ **Example (latest block)**
42
+
43
+ ```ts
44
+ const latestBlock = await blockApi.getLatestBlock()
45
+ console.log(latestBlock)
46
+ ```
47
+
48
+ **Example (latest block at a specific height)**
49
+
50
+ ```ts
51
+ const latestAtHeight = await blockApi.getLatestBlock(120000)
52
+ console.log(latestAtHeight)
53
+ ```
54
+
55
+ ---
56
+
57
+ ## `getBlockByHeight`
58
+
59
+ Query a **specific block by its height**.
60
+ Optionally, you can query the result from a historical chain state.
61
+
62
+ **CLI equivalent**
63
+
64
+ ```bash
65
+ zigchaind query block --type=height <height>
66
+ zigchaind query block --type=height <height> --height <H>
67
+ ```
68
+
69
+ **Method**
70
+
71
+ ```ts
72
+ getBlockByHeight(height: number, atHeight?: number)
73
+ ```
74
+
75
+ **Example (specific block)**
76
+
77
+ ```ts
78
+ const block = await blockApi.getBlockByHeight(150000)
79
+ console.log(block)
80
+ ```
81
+
82
+ **Example (block queried at historical height)**
83
+
84
+ ```ts
85
+ const blockAtHeight = await blockApi.getBlockByHeight(150000, 160000)
86
+ console.log(blockAtHeight)
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Notes
92
+
93
+ * Block queries are **read-only** and do not require any wallet.
94
+ * Querying at historical heights may fail if the node has pruned old data.
95
+ * LCD does **not** support querying blocks by hash (height-based queries only).
96
+
97
+ ---
@@ -0,0 +1,93 @@
1
+ # Circuit Module
2
+
3
+ The **ChainCircuitApi** lets you query **account-level transaction permissions** for the circuit module.
4
+ It is mainly used to check which accounts are **blocked or restricted** from sending transactions on the chain.
5
+
6
+ ---
7
+
8
+ ## Setup
9
+
10
+ ```ts
11
+ import {
12
+ ChainCircuitApi,
13
+ getNetworkEndpoints,
14
+ Network,
15
+ } from '@zuhaibnoor/zigchain-sdk'
16
+
17
+ const endpoints = getNetworkEndpoints(Network.Testnet)
18
+ const circuitApi = new ChainCircuitApi(endpoints)
19
+ ```
20
+
21
+ ---
22
+
23
+ ## `getAccountPermissions`
24
+
25
+ Fetch the **circuit permissions for a specific account**.
26
+
27
+ **CLI equivalent**
28
+
29
+ ```bash
30
+ zigchaind query circuit account <address>
31
+ ```
32
+
33
+ **Method**
34
+
35
+ ```ts
36
+ getAccountPermissions(address: string)
37
+ ```
38
+
39
+ **Parameters**
40
+
41
+ * `address: string` – The account address to query.
42
+
43
+ **Returns**
44
+
45
+ * `CircuitAccountResponse` – Contains whether the account is blocked or restricted.
46
+
47
+ **Example**
48
+
49
+ ```ts
50
+ const address = 'zig1svkn4sqrlz8r6krq96ty6kze54n2ec03u0vat5'
51
+ const permissions = await circuitApi.getAccountPermissions(address)
52
+ console.log(`Circuit permissions for ${address}:`)
53
+ console.dir(permissions, { depth: null })
54
+ ```
55
+
56
+ ---
57
+
58
+ ## `getAllAccountPermissions`
59
+
60
+ Fetch **all accounts with circuit restrictions or permissions**.
61
+
62
+ **CLI equivalent**
63
+
64
+ ```bash
65
+ zigchaind query circuit accounts
66
+ ```
67
+
68
+ **Method**
69
+
70
+ ```ts
71
+ getAllAccountPermissions()
72
+ ```
73
+
74
+ **Returns**
75
+
76
+ * `CircuitAccountsResponse` – Contains a list of all accounts and their circuit permission status.
77
+
78
+ **Example**
79
+
80
+ ```ts
81
+ const allPermissions = await circuitApi.getAllAccountPermissions()
82
+ console.log('All accounts with circuit permissions:')
83
+ console.dir(allPermissions, { depth: null })
84
+ ```
85
+
86
+ ---
87
+
88
+ ## Notes
89
+
90
+ * Useful for **auditing and monitoring** restricted accounts.
91
+ * The `getAllAccountPermissions` method may return large datasets if many accounts are restricted.
92
+
93
+
@@ -0,0 +1,70 @@
1
+ # Comet Validator Set Module
2
+
3
+ The **Comet Validator Set** module allows you to query the **full CometBFT validator set** on ZigChain.
4
+
5
+ Think of it as a way to see **all the nodes that are currently validating blocks** at any given height.
6
+
7
+ ---
8
+
9
+ ## Setup
10
+
11
+ ```ts
12
+ import {
13
+ ChainCometValidatorSetApi,
14
+ getNetworkEndpoints,
15
+ Network
16
+ } from '@zuhaibnoor/zigchain-sdk'
17
+
18
+ const endpoints = getNetworkEndpoints(Network.Testnet)
19
+ const validatorApi = new ChainCometValidatorSetApi(endpoints)
20
+ ```
21
+
22
+ ---
23
+
24
+ ## `fetchValidatorSet(height?: number)`
25
+
26
+ ### What it does
27
+
28
+ Fetches the **full list of validators** for a specific block height.
29
+
30
+ * If `height` is **not provided**, it returns the **latest validator set**.
31
+ * If `height` is provided, it returns the **validator set at that block height**.
32
+
33
+ ---
34
+
35
+ ### Validator Info
36
+
37
+ Each validator object contains:
38
+
39
+ * `operator_address` → the validator’s address
40
+ * `consensus_pubkey` → their public key used for block signing
41
+ * `voting_power` → the validator’s current voting weight
42
+ * `proposer_priority` → used internally to determine which validator proposes the next block
43
+
44
+ ---
45
+
46
+ ### CLI Equivalent
47
+
48
+ ```bash
49
+ # Latest validator set
50
+ zigchaind query comet-validator-set
51
+
52
+ # Validator set at specific height
53
+ zigchaind query comet-validator-set <height>
54
+ ```
55
+
56
+ ---
57
+
58
+ ### Example
59
+
60
+ ```ts
61
+ // Latest validator set
62
+ const latestValidators = await validatorApi.fetchValidatorSet()
63
+ console.dir(latestValidators, { depth: null })
64
+
65
+ // Validator set at height 2990010
66
+ const validatorsAtHeight = await validatorApi.fetchValidatorSet(2990010)
67
+ console.dir(validatorsAtHeight, { depth: null })
68
+ ```
69
+
70
+ ---