@zuhaibnoor/zigchain-sdk 1.0.3 → 1.1.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.
Files changed (185) hide show
  1. package/README.md +1 -1
  2. package/dist/auth/ChainAuthApi.d.ts +0 -3
  3. package/dist/auth/ChainAuthApi.d.ts.map +1 -1
  4. package/dist/auth/ChainAuthApi.js +0 -26
  5. package/dist/auth/ChainAuthApi.js.map +1 -1
  6. package/dist/bank/ChainBankApi.d.ts +0 -9
  7. package/dist/bank/ChainBankApi.d.ts.map +1 -1
  8. package/dist/bank/ChainBankApi.js +0 -18
  9. package/dist/bank/ChainBankApi.js.map +1 -1
  10. package/dist/circuit/ChainCircuitApi.d.ts.map +1 -1
  11. package/dist/circuit/ChainCircuitApi.js.map +1 -1
  12. package/dist/client/http.d.ts +1 -0
  13. package/dist/client/http.d.ts.map +1 -1
  14. package/dist/client/http.js +10 -0
  15. package/dist/client/http.js.map +1 -1
  16. package/dist/dex/ChainDexApi.d.ts.map +1 -1
  17. package/dist/dex/ChainDexApi.js.map +1 -1
  18. package/dist/distribution/ChainDistributionApi.d.ts +47 -0
  19. package/dist/distribution/ChainDistributionApi.d.ts.map +1 -0
  20. package/dist/distribution/ChainDistributionApi.js +74 -0
  21. package/dist/distribution/ChainDistributionApi.js.map +1 -0
  22. package/dist/distribution/types.d.ts +71 -0
  23. package/dist/distribution/types.d.ts.map +1 -0
  24. package/dist/distribution/types.js +2 -0
  25. package/dist/distribution/types.js.map +1 -0
  26. package/dist/evidence/ChainEvidenceApi.d.ts +15 -0
  27. package/dist/evidence/ChainEvidenceApi.d.ts.map +1 -0
  28. package/dist/evidence/ChainEvidenceApi.js +22 -0
  29. package/dist/evidence/ChainEvidenceApi.js.map +1 -0
  30. package/dist/evidence/types.d.ts +15 -0
  31. package/dist/evidence/types.d.ts.map +1 -0
  32. package/dist/evidence/types.js +2 -0
  33. package/dist/evidence/types.js.map +1 -0
  34. package/dist/feegrant/ChainFeegrantApi.d.ts +22 -0
  35. package/dist/feegrant/ChainFeegrantApi.d.ts.map +1 -0
  36. package/dist/feegrant/ChainFeegrantApi.js +32 -0
  37. package/dist/feegrant/ChainFeegrantApi.js.map +1 -0
  38. package/dist/feegrant/types.d.ts +17 -0
  39. package/dist/feegrant/types.d.ts.map +1 -0
  40. package/dist/feegrant/types.js +2 -0
  41. package/dist/feegrant/types.js.map +1 -0
  42. package/dist/ibc/ChainIbcApi.d.ts +55 -0
  43. package/dist/ibc/ChainIbcApi.d.ts.map +1 -0
  44. package/dist/ibc/ChainIbcApi.js +82 -0
  45. package/dist/ibc/ChainIbcApi.js.map +1 -0
  46. package/dist/ibc/ibcChannel/ChainIbcChannelApi.d.ts +55 -0
  47. package/dist/ibc/ibcChannel/ChainIbcChannelApi.d.ts.map +1 -0
  48. package/dist/ibc/ibcChannel/ChainIbcChannelApi.js +82 -0
  49. package/dist/ibc/ibcChannel/ChainIbcChannelApi.js.map +1 -0
  50. package/dist/ibc/ibcChannel/types.d.ts +106 -0
  51. package/dist/ibc/ibcChannel/types.d.ts.map +1 -0
  52. package/dist/ibc/ibcChannel/types.js +2 -0
  53. package/dist/ibc/ibcChannel/types.js.map +1 -0
  54. package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.d.ts +14 -0
  55. package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.d.ts.map +1 -0
  56. package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.js +38 -0
  57. package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.js.map +1 -0
  58. package/dist/ibc/ibcChannelV2/types.d.ts +26 -0
  59. package/dist/ibc/ibcChannelV2/types.d.ts.map +1 -0
  60. package/dist/ibc/ibcChannelV2/types.js +3 -0
  61. package/dist/ibc/ibcChannelV2/types.js.map +1 -0
  62. package/dist/ibc/ibcClient/ChainIbcClientApi.d.ts +15 -0
  63. package/dist/ibc/ibcClient/ChainIbcClientApi.d.ts.map +1 -0
  64. package/dist/ibc/ibcClient/ChainIbcClientApi.js +39 -0
  65. package/dist/ibc/ibcClient/ChainIbcClientApi.js.map +1 -0
  66. package/dist/ibc/ibcClient/types.d.ts +53 -0
  67. package/dist/ibc/ibcClient/types.d.ts.map +1 -0
  68. package/dist/ibc/ibcClient/types.js +2 -0
  69. package/dist/ibc/ibcClient/types.js.map +1 -0
  70. package/dist/ibc/ibcConnection/ChainIbcConnectionApi.d.ts +11 -0
  71. package/dist/ibc/ibcConnection/ChainIbcConnectionApi.d.ts.map +1 -0
  72. package/dist/ibc/ibcConnection/ChainIbcConnectionApi.js +24 -0
  73. package/dist/ibc/ibcConnection/ChainIbcConnectionApi.js.map +1 -0
  74. package/dist/ibc/ibcConnection/types.d.ts +18 -0
  75. package/dist/ibc/ibcConnection/types.d.ts.map +1 -0
  76. package/dist/ibc/ibcConnection/types.js +2 -0
  77. package/dist/ibc/ibcConnection/types.js.map +1 -0
  78. package/dist/ibc/types.d.ts +106 -0
  79. package/dist/ibc/types.d.ts.map +1 -0
  80. package/dist/ibc/types.js +2 -0
  81. package/dist/ibc/types.js.map +1 -0
  82. package/dist/ibc-transfer/ChainIbcTransferApi.d.ts +12 -0
  83. package/dist/ibc-transfer/ChainIbcTransferApi.d.ts.map +1 -0
  84. package/dist/ibc-transfer/ChainIbcTransferApi.js +30 -0
  85. package/dist/ibc-transfer/ChainIbcTransferApi.js.map +1 -0
  86. package/dist/ibc-transfer/types.d.ts +26 -0
  87. package/dist/ibc-transfer/types.d.ts.map +1 -0
  88. package/dist/ibc-transfer/types.js +2 -0
  89. package/dist/ibc-transfer/types.js.map +1 -0
  90. package/dist/index.d.ts +26 -0
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +26 -0
  93. package/dist/index.js.map +1 -1
  94. package/dist/interchain-accounts/ChainInterChainAccApi.d.ts +9 -0
  95. package/dist/interchain-accounts/ChainInterChainAccApi.d.ts.map +1 -0
  96. package/dist/interchain-accounts/ChainInterChainAccApi.js +16 -0
  97. package/dist/interchain-accounts/ChainInterChainAccApi.js.map +1 -0
  98. package/dist/interchain-accounts/types.d.ts +12 -0
  99. package/dist/interchain-accounts/types.d.ts.map +1 -0
  100. package/dist/interchain-accounts/types.js +2 -0
  101. package/dist/interchain-accounts/types.js.map +1 -0
  102. package/dist/networks/endpoints.js +2 -2
  103. package/dist/networks/endpoints.js.map +1 -1
  104. package/dist/runtime/ChainRuntimeApi.d.ts +12 -0
  105. package/dist/runtime/ChainRuntimeApi.d.ts.map +1 -0
  106. package/dist/runtime/ChainRuntimeApi.js +16 -0
  107. package/dist/runtime/ChainRuntimeApi.js.map +1 -0
  108. package/dist/runtime/types.d.ts +4 -0
  109. package/dist/runtime/types.d.ts.map +1 -0
  110. package/dist/runtime/types.js +2 -0
  111. package/dist/runtime/types.js.map +1 -0
  112. package/dist/staking/ChainStakingApi.d.ts +1 -5
  113. package/dist/staking/ChainStakingApi.d.ts.map +1 -1
  114. package/dist/staking/ChainStakingApi.js +9 -7
  115. package/dist/staking/ChainStakingApi.js.map +1 -1
  116. package/dist/tokenwrapper/ChainTokenWrapperApi.d.ts +19 -0
  117. package/dist/tokenwrapper/ChainTokenWrapperApi.d.ts.map +1 -0
  118. package/dist/tokenwrapper/ChainTokenWrapperApi.js +26 -0
  119. package/dist/tokenwrapper/ChainTokenWrapperApi.js.map +1 -0
  120. package/dist/tokenwrapper/types.d.ts +15 -0
  121. package/dist/tokenwrapper/types.d.ts.map +1 -0
  122. package/dist/tokenwrapper/types.js +2 -0
  123. package/dist/tokenwrapper/types.js.map +1 -0
  124. package/dist/txs/ChainTxsApi.d.ts +12 -0
  125. package/dist/txs/ChainTxsApi.d.ts.map +1 -0
  126. package/dist/txs/ChainTxsApi.js +17 -0
  127. package/dist/txs/ChainTxsApi.js.map +1 -0
  128. package/dist/txs/types.d.ts +22 -0
  129. package/dist/txs/types.d.ts.map +1 -0
  130. package/dist/txs/types.js +5 -0
  131. package/dist/txs/types.js.map +1 -0
  132. package/dist/upgrade/ChainUpgradeApi.d.ts +22 -0
  133. package/dist/upgrade/ChainUpgradeApi.d.ts.map +1 -0
  134. package/dist/upgrade/ChainUpgradeApi.js +40 -0
  135. package/dist/upgrade/ChainUpgradeApi.js.map +1 -0
  136. package/dist/upgrade/types.d.ts +24 -0
  137. package/dist/upgrade/types.d.ts.map +1 -0
  138. package/dist/upgrade/types.js +5 -0
  139. package/dist/upgrade/types.js.map +1 -0
  140. package/dist/validator-set/ChainCometValidator.d.ts +8 -0
  141. package/dist/validator-set/ChainCometValidator.d.ts.map +1 -0
  142. package/dist/validator-set/ChainCometValidator.js +15 -0
  143. package/dist/validator-set/ChainCometValidator.js.map +1 -0
  144. package/dist/validator-set/ChainValidator.d.ts +8 -0
  145. package/dist/validator-set/ChainValidator.d.ts.map +1 -0
  146. package/dist/validator-set/ChainValidator.js +15 -0
  147. package/dist/validator-set/ChainValidator.js.map +1 -0
  148. package/dist/validator-set/types.d.ts +18 -0
  149. package/dist/validator-set/types.d.ts.map +1 -0
  150. package/dist/validator-set/types.js +2 -0
  151. package/dist/validator-set/types.js.map +1 -0
  152. package/dist/wasm/ChainWasmApi.d.ts +57 -0
  153. package/dist/wasm/ChainWasmApi.d.ts.map +1 -0
  154. package/dist/wasm/ChainWasmApi.js +78 -0
  155. package/dist/wasm/ChainWasmApi.js.map +1 -0
  156. package/dist/wasm/types.d.ts +77 -0
  157. package/dist/wasm/types.d.ts.map +1 -0
  158. package/dist/wasm/types.js +2 -0
  159. package/dist/wasm/types.js.map +1 -0
  160. package/docs/auth.md +438 -72
  161. package/docs/bank.md +782 -123
  162. package/docs/block-results.md +328 -21
  163. package/docs/block.md +325 -38
  164. package/docs/circuit.md +164 -35
  165. package/docs/dex.md +313 -63
  166. package/docs/distribution.md +772 -0
  167. package/docs/evidence.md +194 -0
  168. package/docs/factory.md +308 -62
  169. package/docs/feegrant.md +206 -0
  170. package/docs/gov.md +364 -0
  171. package/docs/ibc/ibcChannel.md +977 -0
  172. package/docs/ibc/ibcClient.md +771 -0
  173. package/docs/ibc/ibcConnection.md +214 -0
  174. package/docs/ibc-transfer.md +463 -0
  175. package/docs/interchain-accounts.md +223 -0
  176. package/docs/mint.md +270 -0
  177. package/docs/runtime.md +120 -0
  178. package/docs/slashing.md +287 -0
  179. package/docs/staking.md +756 -0
  180. package/docs/tokenwrapper.md +294 -0
  181. package/docs/txs.md +447 -0
  182. package/docs/upgrade.md +356 -0
  183. package/docs/validator-set.md +177 -0
  184. package/docs/wasm.md +916 -0
  185. package/package.json +1 -1
package/docs/wasm.md ADDED
@@ -0,0 +1,916 @@
1
+ # WASM Module
2
+
3
+ ## What is WASM?
4
+
5
+ **WASM (WebAssembly)** is a portable binary instruction format designed to run code safely.
6
+
7
+ In the Cosmos ecosystem (including **ZigChain**), WASM is used through **CosmWasm**, which allows developers to deploy and execute smart contracts on-chain.
8
+
9
+ ---
10
+ # Important Terminology
11
+
12
+ Before documenting functions, let’s define key terms.
13
+
14
+ ### Code
15
+
16
+ **Code** refers to uploaded smart contract bytecode stored on-chain.
17
+
18
+ * It is stored once.
19
+ * It is assigned a unique `code_id`.
20
+ * Multiple contracts can be instantiated from the same code.
21
+
22
+ Think of it like:
23
+
24
+ > Code = Blueprint
25
+ > Contract = Deployed instance of blueprint
26
+
27
+ ---
28
+
29
+ ### Code ID
30
+
31
+ A unique numeric identifier assigned when contract bytecode is uploaded.
32
+
33
+ Example:
34
+
35
+ ```
36
+ code_id = 12
37
+ ```
38
+
39
+ ---
40
+
41
+ ### Contract
42
+
43
+ A deployed instance created from a stored `code_id`.
44
+
45
+ * Has its own unique contract address.
46
+ * Maintains its own state.
47
+ * Can be executed and queried independently.
48
+
49
+ ---
50
+
51
+ ### Contract Address
52
+
53
+ A bech32 address representing a deployed contract.
54
+
55
+ Example:
56
+
57
+ ```
58
+ zig1abcd....
59
+ ```
60
+
61
+ ---
62
+
63
+ ### Contract State
64
+
65
+ The stored key-value data maintained by a contract.
66
+
67
+ ---
68
+
69
+ ### Contract History
70
+
71
+ Tracks migrations and updates related to a contract’s code.
72
+
73
+ ---
74
+
75
+ # Functions Documentation
76
+ Setup:
77
+ ```ts
78
+ import {
79
+ ChainWasmApi,
80
+ getNetworkEndpoints,
81
+ Network
82
+ } from '@zuhaibnoor/zigchain-sdk'
83
+
84
+ const endpoints = getNetworkEndpoints(Network.Testnet)
85
+ const wasmApi = new ChainWasmApi(endpoints)
86
+
87
+ const codeId = '1'
88
+ const contractAddress = 'zig15jqg0hmp9n06q0as7uk3x9xkwr9k3r7yh4ww2uc0hek8zlryrgmsamk4qg'
89
+ const codeHash = '72A7D1420836189D5F3FBE4EDF8AC1246532F18E7CEE67CBEEA5F881DDC482E5'
90
+ const creatorAddress = 'zig1v6q4m8u95hwghzskk59a79gk5zymfp263vkyec'
91
+
92
+ ```
93
+
94
+ # 1️⃣ fetchCode
95
+
96
+ ## Method
97
+
98
+ ```ts
99
+ async fetchCode(codeId: string)
100
+ ```
101
+
102
+ ## CLI Equivalent
103
+
104
+ ```bash
105
+ zigchaind query wasm code <code-id>
106
+ ```
107
+
108
+ ---
109
+
110
+ ## Description
111
+
112
+ Downloads the **raw WASM bytecode** stored on-chain for a given `code_id`.
113
+
114
+ This returns:
115
+
116
+ * Metadata about the code
117
+ * The actual compiled WASM binary (base64 encoded)
118
+
119
+ This is the full smart contract blueprint stored on the chain.
120
+
121
+ ---
122
+
123
+ ## Parameters
124
+
125
+ | Name | Type | Description |
126
+ | ------ | ------ | ----------------------------------------------------- |
127
+ | codeId | string | Unique identifier of the uploaded smart contract code |
128
+
129
+ ---
130
+
131
+ ## Usage Example
132
+
133
+ ```ts
134
+ const code = await wasmApi.fetchCode('1')
135
+ console.dir(code, { depth: null })
136
+ ```
137
+
138
+
139
+
140
+ ## Example Response
141
+
142
+ ```json
143
+ {
144
+ "code_info": {
145
+ "code_id": "1",
146
+ "creator": "zig1v6q4m8u95hwghzskk59a79gk5zymfp263vkyec",
147
+ "data_hash": "72A7D1420836189D5F3FBE4EDF8AC1246532F18E7CEE67CBEEA5F881DDC482E5",
148
+ "instantiate_permission": {
149
+ "permission": "Everybody",
150
+ "addresses": []
151
+ }
152
+ },
153
+ "data": "AGFzbQEAAAAB2gEcYAJ/fwF/YAJ/fwBgA..."
154
+ }
155
+ ```
156
+
157
+
158
+ ## Response Field Explanation
159
+
160
+ ### `code_info`
161
+
162
+ Metadata about the stored contract code.
163
+
164
+ | Field | Description |
165
+ | ---------------------- | ------------------------------------------------------ |
166
+ | code_id | Unique identifier of this uploaded contract |
167
+ | creator | Address that uploaded the contract |
168
+ | data_hash | SHA256 hash of the WASM bytecode |
169
+ | instantiate_permission | Who is allowed to instantiate contracts from this code |
170
+
171
+ ### `data`
172
+
173
+ Base64-encoded WASM binary.
174
+
175
+ ⚠️ This is the actual compiled smart contract.
176
+
177
+
178
+ ## When to Use
179
+
180
+ * Verifying bytecode integrity
181
+ * Downloading contract for auditing
182
+ * Comparing hashes
183
+ * Building explorers or developer tools
184
+
185
+ ---
186
+
187
+ # 2️⃣ fetchCodeInfo
188
+
189
+ ## Method
190
+
191
+ ```ts
192
+ async fetchCodeInfo(codeId: string)
193
+ ```
194
+
195
+ ## CLI Equivalent
196
+
197
+ ```bash
198
+ zigchaind query wasm code-info <code-id>
199
+ ```
200
+
201
+ ## Description
202
+
203
+ Fetches **metadata only** about stored smart contract code.
204
+
205
+ ⚠️ Does NOT return raw WASM bytecode.
206
+
207
+ This is lightweight compared to `fetchCode`.
208
+
209
+ ## Parameters
210
+
211
+ | Name | Type | Description |
212
+ | ------ | ------ | ----------------------------------------------------- |
213
+ | codeId | string | Unique identifier of the uploaded smart contract code |
214
+
215
+
216
+ ## Usage Example
217
+
218
+ ```ts
219
+ const codeInfo = await wasmApi.fetchCodeInfo('1')
220
+ console.dir(codeInfo, { depth: null })
221
+ ```
222
+
223
+
224
+ ## Example Response
225
+
226
+ ```json
227
+ {
228
+ "code_id": "1",
229
+ "creator": "zig1v6q4m8u95hwghzskk59a79gk5zymfp263vkyec",
230
+ "checksum": "72A7D1420836189D5F3FBE4EDF8AC1246532F18E7CEE67CBEEA5F881DDC482E5",
231
+ "instantiate_permission": {
232
+ "permission": "Everybody",
233
+ "addresses": []
234
+ }
235
+ }
236
+ ```
237
+
238
+ ## Response Field Explanation
239
+
240
+ | Field | Description |
241
+ | ---------------------- | ---------------------------------------- |
242
+ | code_id | Unique identifier of the stored contract |
243
+ | creator | Address that uploaded the contract |
244
+ | checksum | SHA256 hash of the WASM bytecode |
245
+ | instantiate_permission | Defines who can instantiate contracts |
246
+
247
+ ### Instantiate Permission Values
248
+
249
+ | Value | Meaning |
250
+ | ----------- | ------------------------------- |
251
+ | Everybody | Anyone can instantiate |
252
+ | OnlyAddress | Only specific addresses allowed |
253
+ | Nobody | Instantiation disabled |
254
+
255
+ ## When to Use
256
+
257
+ * Checking who uploaded code
258
+ * Getting code hash
259
+ * Verifying instantiation permissions
260
+ * Quick metadata lookup without large payload
261
+
262
+ ---
263
+
264
+ # 3️⃣ fetchContractInfo
265
+
266
+ ## Method
267
+
268
+ ```ts
269
+ async fetchContractInfo(contractAddress: string)
270
+ ```
271
+
272
+ ## CLI Equivalent
273
+
274
+ ```bash
275
+ zigchaind query wasm contract <contract-address>
276
+ ```
277
+
278
+ ## Description
279
+
280
+ Fetches metadata about a deployed contract instance.
281
+
282
+ Remember:
283
+
284
+ * Code = blueprint
285
+ * Contract = deployed instance
286
+
287
+ This function tells you details about that deployed instance.
288
+
289
+ ---
290
+
291
+ ## Parameters
292
+
293
+ | Name | Type | Description |
294
+ | --------------- | ------ | ----------------------- |
295
+ | contractAddress | string | Bech32 contract address |
296
+
297
+ ## Usage Example
298
+
299
+ ```ts
300
+ const contractInfo = await wasmApi.fetchContractInfo(contractAddress)
301
+ console.dir(contractInfo, { depth: null })
302
+ ```
303
+
304
+ ## Example Response
305
+
306
+ ```json
307
+ {
308
+ "address": "zig15jqg0hmp9n06q0as7uk3x9xkwr9k3r7yh4ww2uc0hek8zlryrgmsamk4qg",
309
+ "contract_info": {
310
+ "code_id": "38",
311
+ "creator": "zig17a7mlm84taqmd3enrpcxhrwzclj9pga8efz83vrswnnywr8tv26s7mpq30",
312
+ "admin": "zig13cu9679ax3vxkq2n6aqeunfzzknmkjd0fnu5he",
313
+ "label": "Oroswap pair",
314
+ "created": {
315
+ "block_height": "64458",
316
+ "tx_index": "0"
317
+ },
318
+ "ibc_port_id": "",
319
+ "extension": null
320
+ }
321
+ }
322
+ ```
323
+
324
+ ## Response Field Explanation
325
+
326
+ ### `address`
327
+
328
+ The contract’s unique on-chain address.
329
+
330
+ ### `contract_info`
331
+
332
+ | Field | Description |
333
+ | -------------------- | ------------------------------------------- |
334
+ | code_id | Code used to instantiate this contract |
335
+ | creator | Address that instantiated the contract |
336
+ | admin | Address allowed to migrate/upgrade (if set) |
337
+ | label | Human-readable label given at instantiation |
338
+ | created.block_height | Block number when contract was created |
339
+ | created.tx_index | Transaction index inside the block |
340
+ | ibc_port_id | IBC port if contract uses IBC |
341
+ | extension | Optional custom metadata |
342
+
343
+ ## When to Use
344
+
345
+ * Determining which code a contract runs
346
+ * Checking contract admin privileges
347
+ * Auditing contract deployment
348
+ * Building block explorers
349
+ * Verifying contract creator
350
+
351
+ ---
352
+
353
+ # 4️⃣ fetchContractHistory
354
+
355
+ ## Method
356
+
357
+ ```ts
358
+ async fetchContractHistory(contractAddress: string)
359
+ ```
360
+
361
+ ## CLI Equivalent
362
+
363
+ ```bash
364
+ zigchaind query wasm contract-history <contract-address>
365
+ ```
366
+
367
+ ## Description
368
+
369
+ Fetches the **code history of a deployed contract**.
370
+
371
+ This shows:
372
+
373
+ * When the contract was instantiated
374
+ * If it was migrated (upgraded)
375
+ * Which code versions it used over time
376
+
377
+ This is important for auditing and upgrade tracking.
378
+
379
+ ## Parameters
380
+
381
+ | Name | Type | Description |
382
+ | --------------- | ------ | --------------------------------------- |
383
+ | contractAddress | string | Bech32 address of the deployed contract |
384
+
385
+ ## Usage Example
386
+
387
+ ```ts
388
+ const history = await wasmApi.fetchContractHistory(contractAddress)
389
+ console.dir(history, { depth: null })
390
+ ```
391
+
392
+ ## Example Response
393
+
394
+ ```json
395
+ {
396
+ "entries": [
397
+ {
398
+ "operation": "CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT",
399
+ "code_id": "38",
400
+ "updated": {
401
+ "block_height": "64458",
402
+ "tx_index": "0"
403
+ },
404
+ "msg": {
405
+ "pair_type": { "xyk": {} },
406
+ "asset_infos": [
407
+ {
408
+ "native_token": {
409
+ "denom": "coin.zig10rfjm85jmzfhravjwpq3hcdz8ngxg7lxd0drkr.uoro"
410
+ }
411
+ },
412
+ {
413
+ "native_token": { "denom": "uzig" }
414
+ }
415
+ ],
416
+ "token_code_id": 4,
417
+ "factory_addr": "zig17a7mlm84taqmd3enrpcxhrwzclj9pga8efz83vrswnnywr8tv26s7mpq30",
418
+ "init_params": null
419
+ }
420
+ }
421
+ ],
422
+ "pagination": {
423
+ "next_key": null,
424
+ "total": "0"
425
+ }
426
+ }
427
+ ```
428
+
429
+
430
+ ## Response Field Explanation
431
+
432
+ ### `entries`
433
+
434
+ Array of history records.
435
+
436
+ Each entry contains:
437
+
438
+ | Field | Description |
439
+ | -------------------- | ------------------------------------------- |
440
+ | operation | Type of history event (INIT, MIGRATE, etc.) |
441
+ | code_id | Code version used at that time |
442
+ | updated.block_height | Block number when update happened |
443
+ | updated.tx_index | Transaction index in the block |
444
+ | msg | Instantiation or migration message payload |
445
+
446
+
447
+ ### Operation Types
448
+
449
+ | Value | Meaning |
450
+ | -------------------------------------------- | ------------------------- |
451
+ | CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT | Contract was instantiated |
452
+ | CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE | Contract was upgraded |
453
+
454
+
455
+ ## When to Use
456
+
457
+ * Auditing contract upgrades
458
+ * Tracking contract migrations
459
+ * Verifying original instantiation parameters
460
+ * Building blockchain explorers
461
+
462
+ ---
463
+
464
+ # 5️⃣ fetchContractStateAll
465
+
466
+ ## Method
467
+
468
+ ```ts
469
+ async fetchContractStateAll(contractAddress: string)
470
+ ```
471
+
472
+ ## CLI Equivalent
473
+
474
+ ```bash
475
+ zigchaind query wasm contract-state all <contract-address>
476
+ ```
477
+
478
+ ## Description
479
+
480
+ Fetches the **entire raw key-value state** of a contract.
481
+
482
+ ⚠️ Important:
483
+
484
+ * Keys are base64 encoded
485
+ * Values are base64 encoded
486
+ * Can be large for production contracts
487
+
488
+ This returns raw storage — not decoded JSON.
489
+
490
+ ## Parameters
491
+
492
+ | Name | Type | Description |
493
+ | --------------- | ------ | ----------------------- |
494
+ | contractAddress | string | Bech32 contract address |
495
+
496
+ ## Usage Example
497
+
498
+ ```ts
499
+ const stateAll = await wasmApi.fetchContractStateAll(contractAddress)
500
+ console.dir(stateAll, { depth: null })
501
+ ```
502
+
503
+ ## Example Response
504
+
505
+ ```json
506
+ {
507
+ "models": [
508
+ {
509
+ "key": "636F6E666967",
510
+ "value": "eyJwYWlyX2luZm8iOnsiYXNzZXRfaW5mb3MiOlt7..."
511
+ },
512
+ {
513
+ "key": "636F6E74726163745F696E666F",
514
+ "value": "eyJjb250cmFjdCI6Im9yb3N3YXAtcGFpciIsInZlcnNpb24iOiIxLjAuMCJ9"
515
+ }
516
+ ],
517
+ "pagination": {
518
+ "next_key": null,
519
+ "total": "0"
520
+ }
521
+ }
522
+ ```
523
+
524
+ ## Response Field Explanation
525
+
526
+ ### `models`
527
+
528
+ Array of raw storage entries.
529
+
530
+ Each model contains:
531
+
532
+ | Field | Description |
533
+ | ----- | --------------------------- |
534
+ | key | Base64-encoded storage key |
535
+ | value | Base64-encoded stored value |
536
+
537
+ To interpret:
538
+
539
+ 1. Base64 decode the key
540
+ 2. Base64 decode the value
541
+ 3. Parse JSON (if applicable)
542
+
543
+ ## When to Use
544
+
545
+ * Debugging contract storage
546
+ * Writing indexers
547
+ * Full state inspection
548
+ * Advanced developer tooling
549
+
550
+ # 6️⃣ fetchCodeList
551
+
552
+ ## Method
553
+
554
+ ```ts
555
+ async fetchCodeList()
556
+ ```
557
+
558
+ ## CLI Equivalent
559
+
560
+ ```bash
561
+ zigchaind query wasm list-code
562
+ ```
563
+
564
+ ## Description
565
+
566
+ Lists all WASM bytecode uploaded on the chain.
567
+
568
+ Returns metadata for every stored `code_id`.
569
+
570
+ Does NOT return raw bytecode.
571
+
572
+ ## Parameters
573
+
574
+ None.
575
+
576
+ ## Usage Example
577
+
578
+ ```ts
579
+ const codes = await wasmApi.fetchCodeList()
580
+ console.dir(codes, { depth: null })
581
+ ```
582
+
583
+ ## Example Response
584
+
585
+ ```json
586
+ {
587
+ "code_infos": [
588
+ {
589
+ "code_id": "1",
590
+ "creator": "zig1v6q4m8u95hwghzskk59a79gk5zymfp263vkyec",
591
+ "data_hash": "72A7D1420836189D5F3FBE4EDF8AC1246532F18E7CEE67CBEEA5F881DDC482E5",
592
+ "instantiate_permission": {
593
+ "permission": "Everybody",
594
+ "addresses": []
595
+ }
596
+ },
597
+ {
598
+ "code_id": "4",
599
+ "creator": "zig13cu9679ax3vxkq2n6aqeunfzzknmkjd0fnu5he",
600
+ "data_hash": "9E8F583DA5231377E36332C5856A56D653AA0AE2284752BF11ABD2B0E46852AE",
601
+ "instantiate_permission": {
602
+ "permission": "Everybody",
603
+ "addresses": []
604
+ }
605
+ }
606
+ ],
607
+ "pagination": {
608
+ "next_key": "AAAAAAAAAGU=",
609
+ "total": "0"
610
+ }
611
+ }
612
+ ```
613
+
614
+ ---
615
+
616
+ ## Response Field Explanation
617
+
618
+ ### `code_infos`
619
+
620
+ Array of uploaded contract metadata.
621
+
622
+ Each entry includes:
623
+
624
+ | Field | Description |
625
+ | ---------------------- | ------------------------------ |
626
+ | code_id | Unique code identifier |
627
+ | creator | Address that uploaded the code |
628
+ | data_hash | SHA256 hash of the bytecode |
629
+ | instantiate_permission | Who can instantiate contracts |
630
+
631
+ ## When to Use
632
+
633
+ * Listing all uploaded contracts
634
+ * Explorer dashboards
635
+ * Developer discovery tools
636
+ * Auditing chain activity
637
+
638
+ ---
639
+ # 7️⃣ fetchContractsByCode
640
+
641
+ ## Method
642
+
643
+ ```ts
644
+ async fetchContractsByCode(codeId: string)
645
+ ```
646
+
647
+ ## CLI Equivalent
648
+
649
+ ```bash
650
+ zigchaind query wasm list-contract-by-code <code-id>
651
+ ```
652
+
653
+ ## Description
654
+
655
+ Lists **all deployed contract addresses** that were instantiated from a specific `code_id`.
656
+
657
+ Remember:
658
+
659
+ * Code = blueprint
660
+ * Contracts = deployed instances of that blueprint
661
+
662
+ This function tells you every contract created from a given code.
663
+
664
+ ## Parameters
665
+
666
+ | Name | Type | Description |
667
+ | ------ | ------ | ------------------------------------- |
668
+ | codeId | string | Code ID of the uploaded WASM bytecode |
669
+
670
+ ## Usage Example
671
+
672
+ ```ts
673
+ const contractsByCode = await wasmApi.fetchContractsByCode("38")
674
+ console.dir(contractsByCode, { depth: null })
675
+ ```
676
+ ## Example Response
677
+
678
+ ```json
679
+ {
680
+ "contracts": [
681
+ "zig15jqg0hmp9n06q0as7uk3x9xkwr9k3r7yh4ww2uc0hek8zlryrgmsamk4qg",
682
+ "zig1r50m5lafnmctat4xpvwdpzqndynlxt2skhr4fhzh76u0qar2y9hqu74u5h",
683
+ "zig1unc0549k2f0d7mjjyfm94fuz2x53wrx3px0pr55va27grdgmspcqsp4692" ...
684
+ ]
685
+ }
686
+ ```
687
+ ## Response Field Explanation
688
+
689
+ | Field | Description |
690
+ | --------- | ------------------------------------------------------------ |
691
+ | contracts | Array of contract addresses instantiated from the given code |
692
+
693
+ Each entry is a bech32 contract address.
694
+
695
+ ## When to Use
696
+
697
+ * Explorer dashboards
698
+ * Analytics tools
699
+ * Contract discovery by code version
700
+ ---
701
+ # 8️⃣ fetchContractsByCreator
702
+
703
+ ## Method
704
+
705
+ ```ts
706
+ async fetchContractsByCreator(creatorAddress: string)
707
+ ```
708
+
709
+ ## CLI Equivalent
710
+
711
+ ```bash
712
+ zigchaind query wasm list-contracts-by-creator <creator-address>
713
+ ```
714
+
715
+
716
+
717
+ ## Description
718
+
719
+ Lists all contracts instantiated by a specific creator address.
720
+
721
+ This answers:
722
+
723
+ > “Which contracts has this account deployed?”
724
+
725
+ ---
726
+
727
+ ## Parameters
728
+
729
+ | Name | Type | Description |
730
+ | -------------- | ------ | ------------------------------------------ |
731
+ | creatorAddress | string | Bech32 account address of contract creator |
732
+
733
+ ---
734
+
735
+ ## Usage Example
736
+
737
+ ```ts
738
+ const contractsByCreator =
739
+ await wasmApi.fetchContractsByCreator(
740
+ 'zig1v6q4m8u95hwghzskk59a79gk5zymfp263vkyec'
741
+ )
742
+
743
+ console.dir(contractsByCreator, { depth: null })
744
+ ```
745
+
746
+ ## Example Response
747
+
748
+ ```json
749
+ {
750
+ "contract_addresses": [
751
+ "zig1hrpna9v7vs3stzyd4z3xf00676kf78zpe2u5ksvljswn2vnjp3ysyz4xhr",
752
+ "zig10gqyjt6vxx2pr5e2wv98yd3pu8rpcq5vc3mgd0palylzqq5jkj4slgr3k6",
753
+ "zig1yel6f5z7rcmdwjzudf9ku0lgcx7suztmk5q7u0mm4tww0eutcgcqqhl6ah"
754
+ ]
755
+ }
756
+ ```
757
+ ## Response Field Explanation
758
+
759
+ | Field | Description |
760
+ | ------------------ | ---------------------------------------------------- |
761
+ | contract_addresses | Array of contract addresses deployed by this creator |
762
+
763
+ ## When to Use
764
+
765
+ * Tracking developer deployments
766
+ * Building wallet dashboards
767
+ * Creator-based analytics
768
+
769
+ ---
770
+
771
+ # 9️⃣ fetchParams
772
+
773
+ ## Method
774
+
775
+ ```ts
776
+ async fetchParams()
777
+ ```
778
+
779
+ ## CLI Equivalent
780
+
781
+ ```bash
782
+ zigchaind query wasm params
783
+ ```
784
+
785
+ ## Description
786
+
787
+ Fetches the **WASM module parameters** configured at chain level.
788
+
789
+ These parameters control:
790
+
791
+ * Who can upload code
792
+ * Default instantiation permissions
793
+
794
+ These are governance-controlled settings.
795
+
796
+ ## Parameters
797
+
798
+ None.
799
+
800
+
801
+ ## Usage Example
802
+
803
+ ```ts
804
+ const params = await wasmApi.fetchParams()
805
+ console.dir(params, { depth: null })
806
+ ```
807
+
808
+ ## Example Response
809
+
810
+ ```json
811
+ {
812
+ "params": {
813
+ "code_upload_access": {
814
+ "permission": "AnyOfAddresses",
815
+ "addresses": [
816
+ "zig1cvelykm6dsu90e66ydlnmw934pxem8y8ntjlnr",
817
+ "zig1qh5h9vel2hqq762r4skrxjnp0nakscx7xe3edf"
818
+ ]
819
+ },
820
+ "instantiate_default_permission": "Everybody"
821
+ }
822
+ }
823
+ ```
824
+
825
+ ## Response Field Explanation
826
+
827
+ ### `code_upload_access`
828
+
829
+ Controls who can upload WASM code.
830
+
831
+ | Permission Type | Meaning |
832
+ | --------------- | ------------------------------- |
833
+ | Everybody | Anyone can upload code |
834
+ | Nobody | Code upload disabled |
835
+ | AnyOfAddresses | Only specific addresses allowed |
836
+
837
+ ### `instantiate_default_permission`
838
+
839
+ Default permission for instantiating contracts when not explicitly defined.
840
+
841
+ Possible values:
842
+
843
+ * `Everybody`
844
+ * `Nobody`
845
+ * `AnyOfAddresses`
846
+
847
+ ## When to Use
848
+
849
+ * Checking governance configuration
850
+ * Verifying upload permissions
851
+ * Building chain status dashboards
852
+ * Security auditing
853
+
854
+ ---
855
+
856
+ # 🔟 fetchPinnedCodes
857
+
858
+ ## Method
859
+
860
+ ```ts
861
+ async fetchPinnedCodes()
862
+ ```
863
+
864
+ ## CLI Equivalent
865
+
866
+ ```bash
867
+ zigchaind query wasm pinned
868
+ ```
869
+
870
+ ## Description
871
+
872
+ Lists all **pinned code IDs**.
873
+
874
+ Pinned codes are stored in node memory for faster execution.
875
+
876
+ Pinning improves performance for frequently used contracts.
877
+
878
+ ## Parameters
879
+
880
+ None.
881
+
882
+ ## Usage Example
883
+
884
+ ```ts
885
+ const pinned = await wasmApi.fetchPinnedCodes()
886
+ console.dir(pinned, { depth: null })
887
+ ```
888
+
889
+ ## Example Response
890
+
891
+ ```json
892
+ {
893
+ "code_ids": [],
894
+ "pagination": {
895
+ "next_key": null,
896
+ "total": "0"
897
+ }
898
+ }
899
+ ```
900
+
901
+ ---
902
+
903
+ ## Response Field Explanation
904
+
905
+ | Field | Description |
906
+ | ---------- | --------------------------------- |
907
+ | code_ids | Array of pinned code IDs |
908
+
909
+
910
+ ## When to Use
911
+
912
+ * Node performance analysis
913
+ * Advanced chain diagnostics
914
+
915
+ ---
916
+