@zuhaibnoor/zigchain-sdk 1.0.3 → 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 (168) 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 +438 -72
  148. package/docs/bank.md +782 -123
  149. package/docs/block-results.md +328 -21
  150. package/docs/comet-validator-set.md +70 -0
  151. package/docs/distribution.md +201 -0
  152. package/docs/evidence.md +199 -0
  153. package/docs/feegrant.md +206 -0
  154. package/docs/gov.md +166 -0
  155. package/docs/ibc/ibcChannel.md +490 -0
  156. package/docs/ibc/ibcClient.md +302 -0
  157. package/docs/ibc/ibcConnection.md +214 -0
  158. package/docs/ibc-transfer.md +204 -0
  159. package/docs/interchain-accounts.md +120 -0
  160. package/docs/mint.md +133 -0
  161. package/docs/runtime.md +81 -0
  162. package/docs/slashing.md +139 -0
  163. package/docs/staking.md +633 -0
  164. package/docs/tokenwrapper.md +137 -0
  165. package/docs/txs.md +0 -0
  166. package/docs/upgrade.md +133 -0
  167. package/docs/wasm.md +916 -0
  168. package/package.json +1 -1
@@ -1,7 +1,103 @@
1
1
  # Block Results
2
2
 
3
- The **ChainBlockResultsApi** lets you query the **execution results of a committed block**.
4
- It includes transaction logs, events, fees, and validator execution results.
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.
5
101
 
6
102
  ---
7
103
 
@@ -20,45 +116,256 @@ const blockResultsApi = new ChainBlockResultsApi(endpoints)
20
116
 
21
117
  ---
22
118
 
23
- ## `fetchBlockResults`
119
+ # 1️⃣ fetchBlockResults
24
120
 
25
- Fetch the **execution results of a block at a specific height**.
121
+ ## Method
26
122
 
27
- **CLI equivalent**
123
+ ```ts
124
+ async fetchBlockResults(height: number)
125
+ ```
126
+
127
+ ## CLI Equivalent
28
128
 
29
129
  ```bash
30
130
  zigchaind query block-results <height>
31
131
  ```
32
132
 
33
- **Method**
133
+ ---
34
134
 
35
- ```ts
36
- fetchBlockResults(height: number)
37
- ```
135
+ ## Description
38
136
 
39
- **Parameters**
137
+ Fetches the **full execution results for a specific block** by height.
40
138
 
41
- * `height: number` The block height to query.
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.
42
140
 
43
- **Returns**
141
+ This is the most detailed view available for what happened at a specific point in chain history.
44
142
 
45
- * `BlockResultsResponse` Contains transaction results, logs, events, and validator execution info.
143
+ > ⚠️ This function queries the **RPC endpoint** internally, unlike all other SDK modules which use the LCD endpoint.
46
144
 
47
- **Example**
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
48
156
 
49
157
  ```ts
50
- const height = 12345
51
- const results = await blockResultsApi.fetchBlockResults(height)
52
- console.log(`Block Results at height ${height}:`)
158
+ const results = await blockResultsApi.fetchBlockResults(2990050)
53
159
  console.dir(results, { depth: null })
54
160
  ```
55
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
+
56
360
  ---
57
361
 
58
- ## Notes
362
+ ## When to Use
59
363
 
60
- * Only works with **RPC endpoints** (`endpoints.rpc`), LCD endpoints cannot be used.
61
- * Useful for analyzing **transaction success/failure**, events emitted, and validator execution info.
62
- * Querying non-existent or pruned heights may return errors.
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
63
370
 
64
371
  ---
@@ -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
+ ---
@@ -0,0 +1,201 @@
1
+ # Distribution Module
2
+
3
+ The **Distribution module** handles reward distribution in the ZigChain network.
4
+ It manages validator commissions, delegator rewards, community pool funds, and distribution-related parameters.
5
+
6
+ This module allows you to **query how rewards are shared** between validators, delegators, and the community pool.
7
+
8
+ ---
9
+
10
+ ## `ChainDistributionApi`
11
+
12
+ ```ts
13
+ import { ChainDistributionApi } from '@zuhaibnoor/zigchain-sdk'
14
+ ```
15
+
16
+ ---
17
+
18
+ ## Constructor
19
+
20
+ ```ts
21
+ const distribution = new ChainDistributionApi(endpoints)
22
+ ```
23
+
24
+ Initializes the Distribution API using the network’s LCD endpoint.
25
+
26
+ ---
27
+
28
+ ## Functions
29
+
30
+ ---
31
+
32
+ ### `fetchValidatorCommission(validator: string)`
33
+
34
+ **Purpose:**
35
+ Returns the commission accumulated by a specific validator from delegators’ rewards.
36
+
37
+ **When to use:**
38
+ Use this when you want to check how much commission a validator has earned.
39
+
40
+ ```ts
41
+ const commission = await distribution.fetchValidatorCommission(
42
+ 'zigvaloper1...'
43
+ )
44
+ ```
45
+
46
+ ---
47
+
48
+ ### `fetchCommunityPool()`
49
+
50
+ **Purpose:**
51
+ Fetches the total balance of the **community pool**, which is used for governance-approved spending.
52
+
53
+ **When to use:**
54
+ Helpful for governance dashboards or tracking ecosystem funds.
55
+
56
+ ```ts
57
+ const pool = await distribution.fetchCommunityPool()
58
+ ```
59
+
60
+ ---
61
+
62
+ ### `fetchDelegatorValidators(delegator: string)`
63
+
64
+ **Purpose:**
65
+ Returns the list of validators from which a delegator is currently earning rewards.
66
+
67
+ **When to use:**
68
+ Use this to understand which validators are paying rewards to a specific delegator.
69
+
70
+ ```ts
71
+ const validators =
72
+ await distribution.fetchDelegatorValidators('zig1...')
73
+ ```
74
+
75
+ ---
76
+
77
+ ### `fetchDelegatorWithdrawAddress(delegator: string)`
78
+
79
+ **Purpose:**
80
+ Fetches the withdraw address where a delegator’s rewards are sent.
81
+
82
+ **When to use:**
83
+ Useful for checking whether a delegator has set a **custom reward withdrawal address**.
84
+
85
+ ```ts
86
+ const withdrawAddress =
87
+ await distribution.fetchDelegatorWithdrawAddress('zig1...')
88
+ ```
89
+
90
+ ---
91
+
92
+ ### `fetchParams()`
93
+
94
+ **Purpose:**
95
+ Returns the current **distribution parameters**, including community tax and reward configuration.
96
+
97
+ **When to use:**
98
+ Helpful for understanding how rewards are split at the protocol level.
99
+
100
+ ```ts
101
+ const params = await distribution.fetchParams()
102
+ ```
103
+
104
+ ---
105
+
106
+ ## `fetchDelegatorRewards(delegator)`
107
+
108
+ **Purpose:**
109
+ Fetches **all staking rewards** earned by a delegator across **all validators**.
110
+
111
+ **When to use:**
112
+ Use this when you want a complete view of a delegator’s accumulated rewards before withdrawal.
113
+
114
+ **CLI equivalent:**
115
+
116
+ ```
117
+ zigchaind query distribution rewards <delegator-address>
118
+ ```
119
+
120
+ ---
121
+
122
+ ## `fetchDelegatorRewardsByValidator(delegator, validator)`
123
+
124
+ **Purpose:**
125
+ Returns rewards earned by a delegator **from a specific validator only**.
126
+
127
+ **When to use:**
128
+ Helpful when analyzing reward contribution per validator or building validator-specific dashboards.
129
+
130
+ **CLI equivalent:**
131
+
132
+ ```
133
+ zigchaind query distribution rewards-by-validator <delegator> <validator>
134
+ ```
135
+
136
+ ---
137
+
138
+ ## `fetchValidatorSlashes(validator)`
139
+
140
+ **Purpose:**
141
+ Fetches **slashing events** applied to a validator, including the slashing fraction and period.
142
+
143
+ **When to use:**
144
+ Use this to inspect validator misbehavior history and assess validator risk.
145
+
146
+ **CLI equivalent:**
147
+
148
+ ```
149
+ zigchaind query distribution slashes <validator-address>
150
+ ```
151
+
152
+ ---
153
+
154
+ ## `fetchValidatorDistributionInfo(validator)`
155
+
156
+ **Purpose:**
157
+ Returns a validator’s **distribution overview**, including self-bond rewards and commission earned.
158
+
159
+ **When to use:**
160
+ Useful for validators or explorers to understand validator earnings structure.
161
+
162
+ **CLI equivalent:**
163
+
164
+ ```
165
+ zigchaind query distribution validator-distribution-info <validator-address>
166
+ ```
167
+
168
+ ---
169
+
170
+ ## `fetchValidatorOutstandingRewards(validator)`
171
+
172
+ **Purpose:**
173
+ Fetches **unwithdrawn (outstanding) rewards** for a validator and all of its delegations.
174
+
175
+ **When to use:**
176
+ Use this to check pending rewards that have not yet been withdrawn.
177
+
178
+ **CLI equivalent:**
179
+
180
+ ```
181
+ zigchaind query distribution validator-outstanding-rewards <validator-address>
182
+ ```
183
+
184
+ ---
185
+
186
+ ## 📌 Summary
187
+
188
+ | Function | What it tells you |
189
+ | ------------------------------- | ------------------------------------------ |
190
+ | `fetchValidatorCommission` | How much commission a validator has earned |
191
+ | `fetchCommunityPool` | Total funds in the community pool |
192
+ | `fetchDelegatorValidators` | Validators paying rewards to a delegator |
193
+ | `fetchDelegatorWithdrawAddress` | Where delegator rewards are withdrawn |
194
+ | `fetchParams` | Network-wide reward distribution rules |
195
+ | `fetchDelegatorRewards` | Get all staking rewards for a delegator across all validators |
196
+ | `fetchDelegatorRewardsByValidator` | Get delegator rewards from a specific validator |
197
+ | `fetchValidatorSlashes` | Query slashing events applied to a validator |
198
+ | `fetchValidatorDistributionInfo` | Fetch validator commission and self-bond rewards |
199
+ | `fetchValidatorOutstandingRewards` | Get unwithdrawn rewards for a validator |
200
+ ---
201
+