@zuhaibnoor/zigchain-sdk 1.1.0 → 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 (42) hide show
  1. package/README.md +1 -1
  2. package/dist/circuit/ChainCircuitApi.d.ts.map +1 -1
  3. package/dist/circuit/ChainCircuitApi.js.map +1 -1
  4. package/dist/dex/ChainDexApi.d.ts.map +1 -1
  5. package/dist/dex/ChainDexApi.js.map +1 -1
  6. package/dist/distribution/ChainDistributionApi.d.ts.map +1 -1
  7. package/dist/distribution/ChainDistributionApi.js +0 -1
  8. package/dist/distribution/ChainDistributionApi.js.map +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/staking/ChainStakingApi.d.ts +1 -5
  14. package/dist/staking/ChainStakingApi.d.ts.map +1 -1
  15. package/dist/staking/ChainStakingApi.js +9 -7
  16. package/dist/staking/ChainStakingApi.js.map +1 -1
  17. package/dist/upgrade/ChainUpgradeApi.d.ts.map +1 -1
  18. package/dist/validator-set/ChainValidator.d.ts +8 -0
  19. package/dist/validator-set/ChainValidator.d.ts.map +1 -0
  20. package/dist/validator-set/ChainValidator.js +15 -0
  21. package/dist/validator-set/ChainValidator.js.map +1 -0
  22. package/docs/block.md +325 -38
  23. package/docs/circuit.md +164 -35
  24. package/docs/dex.md +313 -63
  25. package/docs/distribution.md +664 -93
  26. package/docs/evidence.md +117 -122
  27. package/docs/factory.md +308 -62
  28. package/docs/gov.md +268 -70
  29. package/docs/ibc/ibcChannel.md +736 -249
  30. package/docs/ibc/ibcClient.md +608 -139
  31. package/docs/ibc-transfer.md +349 -90
  32. package/docs/interchain-accounts.md +151 -48
  33. package/docs/mint.md +173 -36
  34. package/docs/runtime.md +81 -42
  35. package/docs/slashing.md +209 -61
  36. package/docs/staking.md +534 -411
  37. package/docs/tokenwrapper.md +221 -64
  38. package/docs/txs.md +447 -0
  39. package/docs/upgrade.md +281 -58
  40. package/docs/validator-set.md +177 -0
  41. package/package.json +1 -1
  42. package/docs/comet-validator-set.md +0 -70
@@ -1,490 +1,977 @@
1
- # IBC Module
1
+ # IBC Channel Module
2
2
 
3
- The **IBC (Inter-Blockchain Communication)** module allows ZigChain to communicate with other blockchains.
3
+ ## What is IBC?
4
4
 
5
- Think of IBC like a **secure bridge system** between blockchains.
5
+ **IBC (Inter-Blockchain Communication)** is a protocol that allows independent blockchains to securely exchange messages and tokens. ZigChain uses IBC to connect with other Cosmos ecosystem chains.
6
6
 
7
- It works using:
7
+ The IBC stack has four layers that build on each other:
8
8
 
9
- * **Clients** → light verifiers that track another chain
10
- * **Connections** links between two chains
11
- * **Channels** communication lanes built on top of connections
12
- * **Packets** messages or token transfers sent through channels
9
+ ```
10
+ Packets the messages/tokens being transferred
11
+ Channels the lanes packets travel through
12
+ Connections the secured links between two chains
13
+ Clients → light clients that verify the other chain's state
14
+ ```
15
+ ---
13
16
 
14
- # Setup
17
+ ## Important Terminology
15
18
 
16
- ```ts
17
- import {
18
- ChainIbcChannelApi,
19
- getNetworkEndpoints,
20
- Network,
21
- } from '@zuhaibnoor/zigchain-sdk'
19
+ ### Channel
22
20
 
23
- const endpoints = getNetworkEndpoints(Network.Testnet)
24
- const ibcApi = new ChainIbcApi(endpoints)
21
+ A **channel** is a communication lane between a specific port on ZigChain and a specific port on a counterparty chain. All IBC token transfers go through channels. Each channel is built on top of a connection.
22
+
23
+ ```
24
+ channel-0 (ZigChain) ↔ channel-612 (counterparty)
25
25
  ```
26
26
 
27
27
  ---
28
- ## `fetchChannels()`
29
28
 
30
- ### What it does
29
+ ### Port
31
30
 
32
- Returns **all IBC channels** that exist on ZigChain.
31
+ A **port** is an application-level identifier that specifies which module on a chain handles the packets. The standard token transfer port is `transfer`. NFT transfers use `wasm.<contract-address>` ports.
33
32
 
34
- ### What is a Channel?
35
-
36
- A **channel** is like a communication lane between two blockchains.
33
+ ```
34
+ port_id = 'transfer'
35
+ ```
37
36
 
38
- If:
37
+ ---
39
38
 
40
- * Connection = physical cable
41
- * Channel = lane inside that cable
42
- * Packet = message sent through the lane
39
+ ### Channel State
43
40
 
44
- Then this function shows you all those lanes.
41
+ | State | Meaning |
42
+ | ------------ | ---------------------------------------------------------- |
43
+ | `STATE_OPEN` | Channel is active and can send/receive packets |
44
+ | `STATE_INIT` | Channel is being opened — handshake in progress |
45
+ | `STATE_TRYOPEN` | Counterparty acknowledged the open, waiting for confirmation |
46
+ | `STATE_CLOSED` | Channel has been closed — no longer usable |
45
47
 
46
48
  ---
47
49
 
48
- ### CLI equivalent
50
+ ### Channel Ordering
49
51
 
50
- ```bash
51
- zigchaind query ibc channel channels
52
- ```
52
+ | Ordering | Meaning |
53
+ | ------------------ | --------------------------------------------------------------- |
54
+ | `ORDER_UNORDERED` | Packets can be received in any order — used for token transfers |
55
+ | `ORDER_ORDERED` | Packets must be received in sequence — used for ordered apps |
53
56
 
54
- ### Example
57
+ All ZigChain IBC channels use `ORDER_UNORDERED`.
55
58
 
56
- ```ts
57
- const channels = await ibcApi.fetchChannels()
58
- console.dir(channels, { depth: null })
59
- ```
59
+ ---
60
+
61
+ ### Connection Hops
60
62
 
61
- You’ll see:
63
+ The list of connections a channel traverses. For a direct channel this is always one connection. Multi-hop channels (not yet standard) would have multiple hops.
62
64
 
63
- * channel IDs
64
- * port IDs
65
- * connection ID
66
- * whether the channel is OPEN or CLOSED
65
+ ```
66
+ connection_hops = ['connection-0']
67
+ ```
67
68
 
68
69
  ---
69
70
 
70
- ## `fetchChannelClientState()`
71
+ ### Packet Sequence Number
71
72
 
72
- ```ts
73
- fetchChannelClientState(portId: string, channelId: string)
73
+ Every packet sent through a channel gets an incrementing integer sequence number. This prevents duplicates, ensures ordering where required, and allows tracking of specific packets.
74
+
75
+ ```
76
+ sequence = 70
74
77
  ```
75
78
 
76
- ### What it does
79
+ ---
80
+
81
+ ### Packet Commitment
77
82
 
78
- Returns the **client state** associated with a channel.
83
+ A **cryptographic hash** stored on the sending chain when a packet is created. It proves the packet exists and was committed to chain state. Used by the receiving chain to verify the packet is legitimate.
79
84
 
80
85
  ---
81
86
 
82
- ### What is a Client?
87
+ ### Packet Acknowledgement
83
88
 
84
- In IBC, a **client** is a small verifier inside ZigChain that:
89
+ A **confirmation** sent back from the receiving chain after processing a packet. It proves the packet was received and whether it succeeded or failed.
85
90
 
86
- * Tracks another blockchain
87
- * Confirms that the other chain is valid
91
+ ---
88
92
 
89
- It is NOT a user.
90
- It is NOT a wallet.
93
+ ### Packet Receipt
91
94
 
92
- It is a **light client**.
95
+ A record stored on the receiving chain after a packet is processed. Proves the packet was received — used to prevent replay attacks.
93
96
 
94
97
  ---
95
98
 
96
- ### What is State?
99
+ ### Proof Height
97
100
 
98
- "State" simply means the **current stored information** about something.
101
+ The block height at which the returned proof or data was generated.
99
102
 
100
- So:
103
+ ```json
104
+ { "revision_number": "2", "revision_height": "4647092" }
105
+ ```
101
106
 
102
- **Client State = the current verification information about the other chain.**
107
+ `revision_number` is the chain's revision (incremented on resets). `revision_height` is the block number.
103
108
 
104
- It contains:
109
+ ---
105
110
 
106
- * chain ID
107
- * latest height
108
- * trust level
109
- * proof parameters
111
+ ## Setup
110
112
 
111
- ---
113
+ ```ts
114
+ import {
115
+ ChainIbcChannelApi,
116
+ getNetworkEndpoints,
117
+ Network,
118
+ } from '@zuhaibnoor/zigchain-sdk'
112
119
 
113
- ### CLI equivalent
120
+ const endpoints = getNetworkEndpoints(Network.Testnet)
121
+ const ibcChannelApi = new ChainIbcChannelApi(endpoints)
114
122
 
115
- ```bash
116
- zigchaind query ibc channel client-state <port-id> <channel-id>
123
+ const portId = 'transfer'
124
+ const channelId = 'channel-0'
117
125
  ```
118
126
 
119
- ### Example
127
+ ---
128
+
129
+ # 1️⃣ fetchChannels
130
+
131
+ ## Method
120
132
 
121
133
  ```ts
122
- const clientState = await ibcApi.fetchChannelClientState(
123
- 'transfer',
124
- 'channel-0'
125
- )
134
+ async fetchChannels()
135
+ ```
126
136
 
127
- console.dir(clientState, { depth: null })
137
+ ## CLI Equivalent
138
+
139
+ ```bash
140
+ zigchaind query ibc channel channels
128
141
  ```
142
+ ## Description
129
143
 
130
- ---
144
+ Fetches **all IBC channels** registered on ZigChain across all ports and connections.
131
145
 
132
- ## `fetchChannelsByConnection()`
146
+ ## Parameters
147
+
148
+ None.
149
+
150
+ ## Usage Example
133
151
 
134
152
  ```ts
135
- fetchChannelsByConnection(connectionId: string)
153
+ const channels = await ibcChannelApi.fetchChannels()
154
+ console.dir(channels, { depth: null })
136
155
  ```
137
156
 
138
- ### What it does
157
+ ## Example Response
158
+
159
+ ```json
160
+ {
161
+ "channels": [
162
+ {
163
+ "state": "STATE_OPEN",
164
+ "ordering": "ORDER_UNORDERED",
165
+ "counterparty": {
166
+ "port_id": "transfer",
167
+ "channel_id": "channel-612"
168
+ },
169
+ "connection_hops": ["connection-0"],
170
+ "version": "ics20-1",
171
+ "port_id": "transfer",
172
+ "channel_id": "channel-0"
173
+ },
174
+ {
175
+ "state": "STATE_OPEN",
176
+ "ordering": "ORDER_UNORDERED",
177
+ "counterparty": {
178
+ "port_id": "wasm.inj1wvtzf6s4rdpttgvpvgwwfpepv8uw0gxvs5qwxp",
179
+ "channel_id": "channel-77060"
180
+ },
181
+ "connection_hops": ["connection-39"],
182
+ "version": "ics721-1",
183
+ "port_id": "wasm.zig12gmfscd27ercy99t9tlmntljnr87muhtpykygpjssf5m63xrma3qymqjp2",
184
+ "channel_id": "channel-25"
185
+ }
186
+ ],
187
+ "pagination": { "next_key": null, "total": "48" },
188
+ "height": { "revision_number": "2", "revision_height": "4647091" }
189
+ }
190
+ ```
139
191
 
140
- Returns all channels built on a specific connection.
192
+ ## Response Field Explanation
141
193
 
142
- ---
194
+ ### `channels[]`
195
+
196
+ | Field | Description |
197
+ | ---------------- | -------------------------------------------------------------------- |
198
+ | state | Current channel state (`STATE_OPEN`, `STATE_INIT`, etc.) |
199
+ | ordering | Packet ordering mode (`ORDER_UNORDERED` for all ZigChain channels) |
200
+ | counterparty.port_id | Port on the remote chain this channel connects to |
201
+ | counterparty.channel_id | Channel ID on the remote chain |
202
+ | connection_hops | Connection(s) this channel is built on |
203
+ | version | IBC application protocol (`ics20-1` for tokens, `ics721-1` for NFTs)|
204
+ | port_id | Port on ZigChain this channel is bound to |
205
+ | channel_id | ZigChain's channel identifier |
206
+
207
+ ### `height`
143
208
 
144
- ### What is a Connection?
209
+ The block height at which this data was read.
145
210
 
146
- A **connection** is a secure link between two chains.
211
+ ### Channel Types on ZigChain Testnet
147
212
 
148
- You can think of it like:
213
+ | Version | Port Type | Use Case | Example |
214
+ | ---------- | ---------------- | -------------------- | ---------------------- |
215
+ | `ics20-1` | `transfer` | Fungible token IBC | `channel-0` to Axelar |
216
+ | `ics721-1` | `wasm.<address>` | NFT IBC transfers | `channel-25` to Injective |
149
217
 
150
- * Client = verifier
151
- * Connection = secured bridge
152
- * Channel = lane on the bridge
218
+ ## When to Use
153
219
 
154
- A single connection can have multiple channels.
220
+ * Building IBC channel explorers or dashboards
221
+ * Discovering which chains ZigChain is connected to
222
+ * Finding the correct channel ID before initiating an IBC transfer
223
+ * Monitoring for new channel openings or closures
155
224
 
156
225
  ---
157
226
 
158
- ### CLI equivalent
227
+ # 2️⃣ fetchChannelClientState
228
+
229
+ ## Method
230
+
231
+ ```ts
232
+ async fetchChannelClientState(portId: string, channelId: string)
233
+ ```
234
+
235
+ ## CLI Equivalent
159
236
 
160
237
  ```bash
161
- zigchaind query ibc channel connections <connection-id>
238
+ zigchaind query ibc channel client-state <port-id> <channel-id>
162
239
  ```
163
240
 
164
- ### Example
241
+ ## Description
242
+
243
+ Fetches the **IBC light client state** associated with a specific channel.
244
+
245
+ The light client is ZigChain's internal verifier for the counterparty chain. Its state includes the counterparty chain's ID, the latest tracked height, trust parameters, and proof specifications. This tells you what chain is on the other end of the channel and how ZigChain is currently tracking it.
246
+
247
+ ## Parameters
248
+
249
+ | Name | Type | Description |
250
+ | --------- | ------ | ----------------------------------------------------- |
251
+ | portId | string | Port the channel is bound to (e.g. `'transfer'`) |
252
+ | channelId | string | Channel identifier (e.g. `'channel-0'`) |
253
+
254
+ ## Usage Example
165
255
 
166
256
  ```ts
167
- const channels = await ibcApi.fetchChannelsByConnection(
168
- 'connection-0'
169
- )
257
+ const clientState = await ibcChannelApi.fetchChannelClientState('transfer', 'channel-0')
258
+ console.dir(clientState, { depth: null })
259
+ ```
170
260
 
171
- console.dir(channels, { depth: null })
261
+ ## Example Response
262
+
263
+ ```json
264
+ {
265
+ "identified_client_state": {
266
+ "client_id": "07-tendermint-0",
267
+ "client_state": {
268
+ "@type": "/ibc.lightclients.tendermint.v1.ClientState",
269
+ "chain_id": "axelar-testnet-lisbon-3",
270
+ "trust_level": { "numerator": "2", "denominator": "3" },
271
+ "trusting_period": "403200s",
272
+ "unbonding_period": "604800s",
273
+ "max_clock_drift": "40s",
274
+ "frozen_height": { "revision_number": "0", "revision_height": "0" },
275
+ "latest_height": { "revision_number": "3", "revision_height": "26422416" }
276
+ }
277
+ },
278
+ "proof": null,
279
+ "proof_height": { "revision_number": "2", "revision_height": "4647092" }
280
+ }
172
281
  ```
173
282
 
283
+ ## Response Field Explanation
284
+
285
+ ### `identified_client_state`
286
+
287
+ | Field | Description |
288
+ | ---------------- | ------------------------------------------------------------------ |
289
+ | client_id | IBC light client ID tracking this counterparty (`07-tendermint-0`) |
290
+ | client_state.@type | Client implementation type — Tendermint for Cosmos chains |
291
+ | client_state.chain_id | The counterparty chain's chain ID |
292
+ | trust_level | Fraction of validators needed to trust an update (2/3 = standard) |
293
+ | trusting_period | How long a header can be trusted without an update (in seconds) |
294
+ | unbonding_period | Counterparty chain's unbonding period |
295
+ | max_clock_drift | Maximum allowed time difference between chains |
296
+ | frozen_height | If non-zero, the client is frozen due to misbehaviour |
297
+ | latest_height | Most recent counterparty block this client has verified |
298
+
299
+ > `channel-0` connects ZigChain to `axelar-testnet-lisbon-3` via client `07-tendermint-0`. The counterparty is at block height `26,422,416`.
300
+
301
+ > A `frozen_height` of `0` means the client is healthy and not frozen.
302
+
303
+ ## When to Use
304
+
305
+ * Identifying which chain is on the other end of a channel
306
+ * Verifying the light client is not frozen before attempting a transfer
307
+ * Debugging IBC transfer failures caused by expired or outdated clients
308
+ * Chain connectivity dashboards showing counterparty chain details
309
+
174
310
  ---
175
311
 
176
- ## `fetchChannelEnd()`
312
+ # 3️⃣ fetchChannelsByConnection
313
+
314
+ ## Method
177
315
 
178
316
  ```ts
179
- fetchChannelEnd(portId: string, channelId: string)
317
+ async fetchChannelsByConnection(connectionId: string)
180
318
  ```
181
319
 
182
- ### What it does
320
+ ## CLI Equivalent
183
321
 
184
- Returns full details of a specific channel.
322
+ ```bash
323
+ zigchaind query ibc channel connections <connection-id>
324
+ ```
185
325
 
186
- ---
326
+ ## Description
187
327
 
188
- ### Why is it called "Channel End"?
328
+ Fetches **all channels built on a specific connection**.
189
329
 
190
- Because a channel exists on **both chains**.
330
+ A single IBC connection can host multiple channels for different applications. This lets you see all the communication lanes running over a particular secured link between two chains.
191
331
 
192
- Each chain stores its own "end" of the channel.
332
+ ## Parameters
193
333
 
194
- So:
334
+ | Name | Type | Description |
335
+ | ------------ | ------ | ----------------------------------------- |
336
+ | connectionId | string | Connection identifier (e.g. `'connection-0'`) |
195
337
 
196
- * ZigChain has one end
197
- * The other chain has another end
338
+ ## Usage Example
198
339
 
199
- This function shows ZigChain’s side.
340
+ ```ts
341
+ const byConnection = await ibcChannelApi.fetchChannelsByConnection('connection-0')
342
+ console.dir(byConnection, { depth: null })
343
+ ```
200
344
 
201
- ---
345
+ ## Example Response
346
+
347
+ ```json
348
+ {
349
+ "channels": [
350
+ {
351
+ "state": "STATE_OPEN",
352
+ "ordering": "ORDER_UNORDERED",
353
+ "counterparty": { "port_id": "transfer", "channel_id": "channel-612" },
354
+ "connection_hops": ["connection-0"],
355
+ "version": "ics20-1",
356
+ "port_id": "transfer",
357
+ "channel_id": "channel-0"
358
+ },
359
+ {
360
+ "state": "STATE_OPEN",
361
+ "ordering": "ORDER_UNORDERED",
362
+ "counterparty": { "port_id": "transfer", "channel_id": "channel-614" },
363
+ "connection_hops": ["connection-0"],
364
+ "version": "ics20-1",
365
+ "port_id": "transfer",
366
+ "channel_id": "channel-1"
367
+ }
368
+ ],
369
+ "pagination": { "next_key": null, "total": "2" },
370
+ "height": { "revision_number": "2", "revision_height": "4647092" }
371
+ }
372
+ ```
202
373
 
203
- ### CLI equivalent
374
+ ## Response Field Explanation
204
375
 
205
- ```bash
206
- zigchaind query ibc channel end <port-id> <channel-id>
207
- ```
376
+ Same channel object structure as `fetchChannels`. See that section for full field descriptions.
208
377
 
209
378
  ---
210
379
 
211
- ## `fetchNextSequenceReceive()`
380
+ # 4️⃣ fetchChannelEnd
381
+
382
+ ## Method
212
383
 
213
384
  ```ts
214
- fetchNextSequenceReceive(portId: string, channelId: string)
385
+ async fetchChannelEnd(portId: string, channelId: string)
386
+ ```
387
+
388
+ ## CLI Equivalent
389
+
390
+ ```bash
391
+ zigchaind query ibc channel end <port-id> <channel-id>
215
392
  ```
216
393
 
217
- ### What it does
394
+ ## Description
218
395
 
219
- Returns the **next packet number ZigChain expects to receive**.
396
+ Fetches the **channel end** ZigChain's stored state for a specific channel.
220
397
 
221
- ---
398
+ A channel exists on both chains simultaneously; each chain stores its own "end." This function returns ZigChain's end, which includes the channel's state, ordering, counterparty identifiers, connection, and version. It is the single-channel equivalent of an entry in `fetchChannels`.
222
399
 
223
- ### What is a Sequence?
400
+ ## Parameters
224
401
 
225
- Every packet sent through a channel gets a number:
402
+ | Name | Type | Description |
403
+ | --------- | ------ | ------------------------------------------------ |
404
+ | portId | string | Port the channel is bound to (e.g. `'transfer'`) |
405
+ | channelId | string | Channel identifier (e.g. `'channel-0'`) |
226
406
 
227
- 1
228
- 2
229
- 3
230
- 4
407
+ ## Usage Example
231
408
 
232
- This number is called a **sequence number**.
409
+ ```ts
410
+ const channelEnd = await ibcChannelApi.fetchChannelEnd('transfer', 'channel-0')
411
+ console.dir(channelEnd, { depth: null })
412
+ ```
233
413
 
234
- It ensures:
414
+ ## Example Response
415
+
416
+ ```json
417
+ {
418
+ "channel": {
419
+ "state": "STATE_OPEN",
420
+ "ordering": "ORDER_UNORDERED",
421
+ "counterparty": { "port_id": "transfer", "channel_id": "channel-612" },
422
+ "connection_hops": ["connection-0"],
423
+ "version": "ics20-1"
424
+ },
425
+ "proof": null,
426
+ "proof_height": { "revision_number": "2", "revision_height": "4647092" }
427
+ }
428
+ ```
235
429
 
236
- * No duplicates
237
- * No skipped packets
238
- * Proper ordering
430
+ ## Response Field Explanation
239
431
 
240
- ---
432
+ ### `channel`
241
433
 
242
- ### So what is "Next Sequence Receive"?
434
+ | Field | Description |
435
+ | --------------- | ------------------------------------------------------- |
436
+ | state | Current channel state |
437
+ | ordering | Packet ordering mode |
438
+ | counterparty | Port and channel ID on the remote chain |
439
+ | connection_hops | Connection(s) this channel uses |
440
+ | version | IBC application protocol version |
243
441
 
244
- It means:
442
+ ### `fetchChannels` vs `fetchChannelEnd`
245
443
 
246
- > “What is the next packet number I am waiting to receive?”
444
+ | Feature | fetchChannels | fetchChannelEnd |
445
+ | --------------------- | ----------------------- | ---------------------------- |
446
+ | Scope | All channels | Single channel |
447
+ | Includes channel ID | ✅ Yes | ❌ No (you provide it) |
448
+ | Includes proof_height | ❌ No | ✅ Yes |
449
+ | Use case | Full channel discovery | Single channel verification |
247
450
 
248
- If it returns `15`,
249
- that means ZigChain has already received up to 14.
451
+ ## When to Use
452
+
453
+ * Verifying a specific channel is open before initiating a transfer
454
+ * Checking counterparty channel and port for a known channel
250
455
 
251
456
  ---
252
457
 
253
- ### CLI equivalent
458
+ # 5️⃣ fetchNextSequenceReceive
459
+
460
+ ## Method
461
+
462
+ ```ts
463
+ async fetchNextSequenceReceive(portId: string, channelId: string)
464
+ ```
465
+
466
+ ## CLI Equivalent
254
467
 
255
468
  ```bash
256
469
  zigchaind query ibc channel next-sequence-receive <port-id> <channel-id>
257
470
  ```
258
471
 
259
- ---
472
+ ## Description
260
473
 
261
- ## `fetchNextSequenceSend()`
474
+ Fetches the **next packet sequence number ZigChain expects to receive** on a channel.
475
+
476
+ If this returns `15`, ZigChain has already processed packets 1–14 and is waiting for packet 15. A value of `0` on ZigChain testnet's `channel-0` reflects that this channel is primarily used for outbound transfers.
477
+
478
+ ## Parameters
479
+
480
+ | Name | Type | Description |
481
+ | --------- | ------ | ------------------------------------------------ |
482
+ | portId | string | Port the channel is bound to (e.g. `'transfer'`) |
483
+ | channelId | string | Channel identifier (e.g. `'channel-0'`) |
484
+
485
+ ## Usage Example
262
486
 
263
487
  ```ts
264
- fetchNextSequenceSend(portId: string, channelId: string)
488
+ const nextRecv = await ibcChannelApi.fetchNextSequenceReceive('transfer', 'channel-0')
489
+ console.dir(nextRecv, { depth: null })
265
490
  ```
266
491
 
267
- ### What it does
492
+ ## Example Response
268
493
 
269
- Returns the next packet number that will be used when sending a packet.
494
+ ```json
495
+ {
496
+ "next_sequence_receive": "0",
497
+ "proof": null,
498
+ "proof_height": { "revision_number": "2", "revision_height": "4647093" }
499
+ }
500
+ ```
270
501
 
271
- ---
502
+ ## Response Field Explanation
272
503
 
273
- ### What does this mean?
504
+ | Field | Description |
505
+ | --------------------- | ---------------------------------------------------------------------- |
506
+ | next_sequence_receive | The next packet sequence this chain expects to receive on this channel |
507
+ | proof | Merkle proof (null for simple queries) |
508
+ | proof_height | Block height at which this data was read |
274
509
 
275
- If it returns `20`,
276
- then the next packet you send will be sequence number 20.
510
+ ## When to Use
277
511
 
278
- This helps track outgoing transfers.
512
+ * Monitoring incoming packet delivery progress
513
+ * Detecting stuck inbound packets
514
+ * Verifying a channel is actively receiving packets
279
515
 
280
516
  ---
281
517
 
282
- ### CLI equivalent
518
+ # 6️⃣ fetchNextSequenceSend
519
+
520
+ ## Method
521
+
522
+ ```ts
523
+ async fetchNextSequenceSend(portId: string, channelId: string)
524
+ ```
525
+
526
+ ## CLI Equivalent
283
527
 
284
528
  ```bash
285
529
  zigchaind query ibc channel next-sequence-send <port-id> <channel-id>
286
530
  ```
287
531
 
288
- ---
532
+ ## Description
533
+
534
+ Fetches the **next packet sequence number that will be assigned** when a new packet is sent on this channel.
535
+
536
+ If this returns `74`, then 73 packets have already been sent and the next outbound transfer on this channel will be sequence `74`.
537
+
538
+ ## Parameters
289
539
 
290
- ## `fetchPacketAcknowledgement()`
540
+ | Name | Type | Description |
541
+ | --------- | ------ | ------------------------------------------------ |
542
+ | portId | string | Port the channel is bound to (e.g. `'transfer'`) |
543
+ | channelId | string | Channel identifier (e.g. `'channel-0'`) |
544
+
545
+ ## Usage Example
291
546
 
292
547
  ```ts
293
- fetchPacketAcknowledgement(
294
- portId: string,
295
- channelId: string,
296
- sequence: number | string
297
- )
548
+ const nextSend = await ibcChannelApi.fetchNextSequenceSend('transfer', 'channel-0')
549
+ console.dir(nextSend, { depth: null })
298
550
  ```
299
551
 
300
- ### What it does
552
+ ## Example Response
553
+
554
+ ```json
555
+ {
556
+ "next_sequence_send": "74",
557
+ "proof": null,
558
+ "proof_height": { "revision_number": "2", "revision_height": "4647093" }
559
+ }
560
+ ```
561
+
562
+ ## Response Field Explanation
563
+
564
+ | Field | Description |
565
+ | ----------------- | ----------------------------------------------------------------- |
566
+ | next_sequence_send | The sequence number the next outbound packet will be assigned |
567
+ | proof | Merkle proof (null for simple queries) |
568
+ | proof_height | Block height at which this data was read |
569
+
570
+ ## When to Use
301
571
 
302
- Returns the acknowledgement for a specific packet.
572
+ * Tracking total outbound transfer volume on a channel
573
+ * Predicting the sequence number of the next transfer
574
+ * Auditing outbound packet counts
303
575
 
304
576
  ---
305
577
 
306
- ### What is an Acknowledgement?
578
+ # 7️⃣ fetchPacketAcknowledgement
307
579
 
308
- When a packet is sent to another chain:
580
+ ## Method
309
581
 
310
- 1. It gets processed there.
311
- 2. The other chain sends back a confirmation.
312
- 3. That confirmation is called an **acknowledgement**.
582
+ ```ts
583
+ async fetchPacketAcknowledgement(portId: string, channelId: string, sequence: number | string)
584
+ ```
313
585
 
314
- Think of it like:
586
+ ## CLI Equivalent
315
587
 
316
- * You send a parcel 📦
317
- * Receiver signs and confirms delivery
318
- * That confirmation = acknowledgement
588
+ ```bash
589
+ zigchaind query ibc channel packet-ack <port-id> <channel-id> <sequence>
590
+ ```
319
591
 
320
- ---
592
+ ## Description
593
+
594
+ Fetches the **acknowledgement stored for a specific packet**.
321
595
 
322
- ### Why is this important?
596
+ When a packet is processed on the counterparty chain, it sends back an acknowledgement that ZigChain stores. This acknowledgement proves the packet was received and contains information about whether processing succeeded or failed.
323
597
 
324
- It proves:
598
+ ## Parameters
325
599
 
326
- * The packet was received
327
- * The packet was processed successfully (or failed)
600
+ | Name | Type | Description |
601
+ | --------- | ----------------- | ------------------------------------------------ |
602
+ | portId | string | Port the channel is bound to |
603
+ | channelId | string | Channel identifier |
604
+ | sequence | number \| string | Packet sequence number to query |
328
605
 
606
+ ## Usage Example
607
+
608
+ ```ts
609
+ const ack = await ibcChannelApi.fetchPacketAcknowledgement('transfer', 'channel-0', 70)
610
+ console.dir(ack, { depth: null })
611
+ ```
612
+
613
+ ## Example Response
614
+
615
+ ```json
616
+ {
617
+ "acknowledgement": "CPdVftUYJv4Y2EUSvyTsdQAe268hI6R333KgqfNkCnw=",
618
+ "proof": null,
619
+ "proof_height": { "revision_number": "2", "revision_height": "4647093" }
620
+ }
621
+ ```
622
+
623
+ ## Response Field Explanation
624
+
625
+ | Field | Description |
626
+ | --------------- | ------------------------------------------------------------------------ |
627
+ | acknowledgement | Base64-encoded acknowledgement data returned by the counterparty chain |
628
+ | proof | Merkle proof (null for simple queries) |
629
+ | proof_height | Block height at which this data was read |
630
+
631
+ ## When to Use
632
+
633
+ * Verifying a specific packet was acknowledged by the counterparty
634
+ * Checking whether a transfer succeeded or failed on the remote chain
635
+ * Building packet status trackers for IBC explorers
329
636
  ---
330
637
 
331
- ### CLI equivalent
638
+ # 8️⃣ fetchPacketCommitment
639
+
640
+ ## Method
641
+
642
+ ```ts
643
+ async fetchPacketCommitment(portId: string, channelId: string, sequence: number | string)
644
+ ```
645
+
646
+ ## CLI Equivalent
332
647
 
333
648
  ```bash
334
- zigchaind query ibc channel packet-ack <port-id> <channel-id> <sequence>
649
+ zigchaind query ibc channel packet-commitment <port-id> <channel-id> <sequence>
335
650
  ```
336
651
 
652
+ ## Description
653
+
654
+ Fetches the **packet commitment** stored for a specific outbound packet.
655
+
656
+ When ZigChain sends a packet, it stores a cryptographic hash (commitment) of that packet. This commitment remains on-chain until the packet is acknowledged by the counterparty. If a commitment exists, it means the packet was sent but the acknowledgement has not yet been received back.
657
+
337
658
  ---
338
659
 
339
- ## `fetchPacketCommitment()`
660
+ ## Parameters
661
+
662
+ | Name | Type | Description |
663
+ | --------- | ----------------- | -------------------------------------------- |
664
+ | portId | string | Port the channel is bound to |
665
+ | channelId | string | Channel identifier |
666
+ | sequence | number \| string | Packet sequence number to query |
667
+
668
+ ## Usage Example
340
669
 
341
670
  ```ts
342
- async fetchPacketCommitment(
343
- portId: string,
344
- channelId: string,
345
- sequence: number | string
346
- )
671
+ const commitment = await ibcChannelApi.fetchPacketCommitment('transfer', 'channel-0', 55)
672
+ console.dir(commitment, { depth: null })
347
673
  ```
348
674
 
349
- ### Description
675
+ ## Example Response
350
676
 
351
- Queries the **packet commitment** for a specific packet sequence.
677
+ ```json
678
+ {
679
+ "commitment": "TGCM/XS6O6oh0TgzrQfICRxgJ0Fxb2AerhtOtSfaG3U=",
680
+ "proof": null,
681
+ "proof_height": { "revision_number": "2", "revision_height": "4647094" }
682
+ }
683
+ ```
684
+
685
+ ## Response Field Explanation
352
686
 
353
- A **packet commitment** is a cryptographic record stored on the sending chain when a packet is sent.
354
- It proves that the packet was created and committed to state.
687
+ | Field | Description |
688
+ | ------------ | ------------------------------------------------------------------------ |
689
+ | commitment | Base64-encoded hash of the packet data — proves the packet was committed |
690
+ | proof | Merkle proof (null for simple queries) |
691
+ | proof_height | Block height at which this data was read |
355
692
 
356
- This function answers:
693
+ ## When to Use
357
694
 
358
- > “Was packet `<sequence>` committed on this channel?”
695
+ * Checking if a specific packet is still awaiting acknowledgement
696
+ * Debugging in-flight or stuck transfers
359
697
 
360
698
  ---
361
699
 
362
- ### Parameters
700
+ # 9️⃣ fetchPacketCommitments
363
701
 
364
- * **portId** – The application port (e.g., `"transfer"`).
365
- * **channelId** – The IBC channel identifier (e.g., `"channel-0"`).
366
- * **sequence** – The packet sequence number.
702
+ ## Method
367
703
 
368
- ---
704
+ ```ts
705
+ async fetchPacketCommitments(portId: string, channelId: string)
706
+ ```
369
707
 
370
- ## `fetchPacketCommitments()`
708
+ ## CLI Equivalent
709
+
710
+ ```bash
711
+ zigchaind query ibc channel packet-commitments <port-id> <channel-id>
712
+ ```
713
+
714
+ ## Description
715
+
716
+ Fetches **all outstanding packet commitments** on a channel — every packet that has been sent but not yet acknowledged.
717
+
718
+ ## Parameters
719
+
720
+ | Name | Type | Description |
721
+ | --------- | ------ | ------------------------------------------------ |
722
+ | portId | string | Port the channel is bound to (e.g. `'transfer'`) |
723
+ | channelId | string | Channel identifier (e.g. `'channel-0'`) |
724
+
725
+ ## Usage Example
371
726
 
372
727
  ```ts
373
- async fetchPacketCommitments(
374
- portId: string,
375
- channelId: string
376
- )
728
+ const commitments = await ibcChannelApi.fetchPacketCommitments('transfer', 'channel-0')
729
+ console.dir(commitments, { depth: null })
377
730
  ```
378
731
 
379
- ### Description
732
+ ## Example Response
733
+
734
+ ```json
735
+ {
736
+ "commitments": [
737
+ {
738
+ "port_id": "transfer",
739
+ "channel_id": "channel-0",
740
+ "sequence": "53",
741
+ "data": "o6Kf3yL0iV5BVzwm0O/j8sOHy+bvO0foTqBgBZx0Bt4="
742
+ },
743
+ {
744
+ "port_id": "transfer",
745
+ "channel_id": "channel-0",
746
+ "sequence": "54",
747
+ "data": "Hn9W269hLobcNGLWmTMDXI8ITsXlEUubBdR3pjYOyTI="
748
+ },
749
+ {
750
+ "port_id": "transfer",
751
+ "channel_id": "channel-0",
752
+ "sequence": "55",
753
+ "data": "TGCM/XS6O6oh0TgzrQfICRxgJ0Fxb2AerhtOtSfaG3U="
754
+ }
755
+ ],
756
+ "pagination": { "next_key": null, "total": "3" },
757
+ "height": { "revision_number": "2", "revision_height": "4647094" }
758
+ }
759
+ ```
380
760
 
381
- Queries **all packet commitments** for a given channel and port.
761
+ ## Response Field Explanation
382
762
 
383
- This returns all packets that:
763
+ ### `commitments[]`
384
764
 
385
- * Were sent from this chain
386
- * Still have commitments stored
765
+ | Field | Description |
766
+ | ---------- | --------------------------------------------------------------- |
767
+ | port_id | Port this commitment belongs to |
768
+ | channel_id | Channel this commitment belongs to |
769
+ | sequence | Packet sequence number |
770
+ | data | Base64-encoded commitment hash of the packet |
387
771
 
388
- It is useful to see all outstanding or tracked packets on a channel.
772
+ ### `fetchPacketCommitment` vs `fetchPacketCommitments`
773
+
774
+ | Feature | fetchPacketCommitment | fetchPacketCommitments |
775
+ | ------------------- | ------------------------- | ------------------------------- |
776
+ | Scope | Single sequence | All outstanding commitments |
777
+ | Use case | Check one specific packet | Overview of all in-flight packets |
389
778
 
390
779
  ---
391
780
 
392
- ### Parameters
781
+ # 🔟 fetchPacketReceipt
782
+
783
+ ## Method
393
784
 
394
- * **portId** – The application port.
395
- * **channelId** The IBC channel identifier.
785
+ ```ts
786
+ async fetchPacketReceipt(portId: string, channelId: string, sequence: number | string)
787
+ ```
788
+
789
+ ## CLI Equivalent
790
+
791
+ ```bash
792
+ zigchaind query ibc channel packet-receipt <port-id> <channel-id> <sequence>
793
+ ```
794
+
795
+ ## Description
796
+
797
+ Checks whether a **specific inbound packet has been received** by ZigChain.
798
+
799
+ A packet receipt is stored on the receiving chain after the packet is processed. This is the definitive proof that ZigChain received and executed a specific packet from the counterparty. Returns `received: true` if the packet was processed, `false` if not.
800
+
801
+ ## Parameters
802
+
803
+ | Name | Type | Description |
804
+ | --------- | ----------------- | -------------------------------------------- |
805
+ | portId | string | Port the channel is bound to |
806
+ | channelId | string | Channel identifier |
807
+ | sequence | number \| string | Packet sequence number to check |
396
808
 
397
809
  ---
398
810
 
399
- ## `fetchPacketReceipt()`
811
+ ## Usage Example
400
812
 
401
813
  ```ts
402
- async fetchPacketReceipt(
403
- portId: string,
404
- channelId: string,
405
- sequence: number | string
406
- )
814
+ const receipt = await ibcChannelApi.fetchPacketReceipt('transfer', 'channel-0', 70)
815
+ console.dir(receipt, { depth: null })
407
816
  ```
408
817
 
409
- ### Description
818
+ ## Example Response
410
819
 
411
- Queries the **packet receipt** for a specific packet.
820
+ ```json
821
+ {
822
+ "received": true,
823
+ "proof": null,
824
+ "proof_height": { "revision_number": "2", "revision_height": "4647094" }
825
+ }
826
+ ```
412
827
 
413
- A **packet receipt** is stored on the receiving chain after a packet is successfully processed.
414
- It confirms that the packet was received.
828
+ ## Response Field Explanation
415
829
 
416
- This function answers:
830
+ | Field | Description |
831
+ | ------------ | ------------------------------------------------------------------ |
832
+ | received | `true` if ZigChain has received and processed this packet |
833
+ | proof | Merkle proof (null for simple queries) |
834
+ | proof_height | Block height at which this data was read |
417
835
 
418
- > “Has packet `<sequence>` been received on this chain?”
836
+ ## When to Use
419
837
 
838
+ * Verifying an inbound packet was successfully received
839
+ * Confirming an incoming IBC transfer reached ZigChain
420
840
  ---
421
841
 
422
- ### Parameters
842
+ # 1️⃣1️⃣ fetchUnreceivedAcks
423
843
 
424
- * **portId** – The application port.
425
- * **channelId** – The IBC channel identifier.
426
- * **sequence** – The packet sequence number.
844
+ ## Method
427
845
 
428
- ---
846
+ ```ts
847
+ async fetchUnreceivedAcks(portId: string, channelId: string, sequences: (number | string)[])
848
+ ```
429
849
 
430
- ## `fetchUnreceivedAcks()`
850
+ ## CLI Equivalent
851
+
852
+ ```bash
853
+ zigchaind query ibc channel unreceived-acks <port-id> <channel-id> <sequences>
854
+ ```
855
+
856
+ ## Description
857
+
858
+ Given a list of packet sequences, returns which ones have **acknowledgements that ZigChain has not yet received back**.
859
+
860
+ This identifies packets that were sent from ZigChain, processed on the counterparty, but whose acknowledgements haven't been relayed back to ZigChain yet. These are packets with commitments still stored on ZigChain waiting to be cleared.
861
+
862
+ ## Parameters
863
+
864
+ | Name | Type | Description |
865
+ | --------- | ----------------------- | -------------------------------------------------------- |
866
+ | portId | string | Port the channel is bound to |
867
+ | channelId | string | Channel identifier |
868
+ | sequences | (number \| string)[] | List of sequence numbers to check for missing acks |
869
+
870
+ ## Usage Example
431
871
 
432
872
  ```ts
433
- async fetchUnreceivedAcks(
434
- portId: string,
435
- channelId: string,
436
- sequences: (number | string)[]
873
+ const unreceivedAcks = await ibcChannelApi.fetchUnreceivedAcks(
874
+ 'transfer',
875
+ 'channel-0',
876
+ [53, 54, 71]
437
877
  )
878
+ console.dir(unreceivedAcks, { depth: null })
438
879
  ```
439
880
 
440
- ### Description
881
+ ## Example Response
441
882
 
442
- Checks which packet acknowledgements have **not yet been received**.
883
+ ```json
884
+ {
885
+ "sequences": ["53", "54"],
886
+ "height": { "revision_number": "2", "revision_height": "4647095" }
887
+ }
888
+ ```
889
+
890
+ ## Response Field Explanation
443
891
 
444
- An **acknowledgement (ack)** is a confirmation sent back to the original chain after a packet is processed on the counterparty chain.
892
+ | Field | Description |
893
+ | --------- | ---------------------------------------------------------------------------------- |
894
+ | sequences | The subset of queried sequences whose acknowledgements have not yet been received |
895
+ | height | Block height at which this data was read |
445
896
 
446
- This function answers:
897
+ ## When to Use
447
898
 
448
- > “Out of these sequences, which acknowledgements are still missing?”
899
+ * Checking which packets need ack relaying
900
+ * Identifying the workload for an IBC relayer
901
+ * Monitoring channel health and ack latency
902
+ * Alerting when acks are pending for too long
449
903
 
450
904
  ---
451
905
 
452
- ### Parameters
906
+ # 1️⃣2️⃣ fetchUnreceivedPackets
453
907
 
454
- * **portId** – The application port.
455
- * **channelId** – The IBC channel identifier.
456
- * **sequences** – List of packet sequence numbers to check.
908
+ ## Method
457
909
 
458
- ---
910
+ ```ts
911
+ async fetchUnreceivedPackets(portId: string, channelId: string, sequences: (number | string)[])
912
+ ```
913
+
914
+ ## CLI Equivalent
915
+
916
+ ```bash
917
+ zigchaind query ibc channel unreceived-packets <port-id> <channel-id> <sequences>
918
+ ```
919
+
920
+ ## Description
921
+
922
+ Given a list of packet sequences, returns which ones have been **committed on the counterparty but not yet received by ZigChain**.
923
+
924
+ This is the inbound counterpart to `fetchUnreceivedAcks` — it identifies packets sent to ZigChain that haven't arrived yet. An empty result means all queried packets have already been received.
925
+
926
+
927
+ ## Parameters
459
928
 
460
- ## `fetchUnreceivedPackets()`
929
+ | Name | Type | Description |
930
+ | --------- | ----------------------- | --------------------------------------------------------- |
931
+ | portId | string | Port the channel is bound to |
932
+ | channelId | string | Channel identifier |
933
+ | sequences | (number \| string)[] | List of sequence numbers to check for missing receipts |
934
+
935
+ ## Usage Example
461
936
 
462
937
  ```ts
463
- async fetchUnreceivedPackets(
464
- portId: string,
465
- channelId: string,
466
- sequences: (number | string)[]
938
+ const unreceivedPackets = await ibcChannelApi.fetchUnreceivedPackets(
939
+ 'transfer',
940
+ 'channel-0',
941
+ [53, 54, 71]
467
942
  )
943
+ console.dir(unreceivedPackets, { depth: null })
468
944
  ```
469
945
 
470
- ### Description
946
+ ## Example Response
471
947
 
472
- Checks which packets have been committed but **not yet received** on the counterparty chain.
948
+ ```json
949
+ {
950
+ "sequences": [],
951
+ "height": { "revision_number": "2", "revision_height": "4647095" }
952
+ }
953
+ ```
473
954
 
474
- This helps detect pending or stuck packets.
955
+ ## Response Field Explanation
475
956
 
476
- This function answers:
957
+ | Field | Description |
958
+ | --------- | -------------------------------------------------------------------------------- |
959
+ | sequences | The subset of queried sequences that have not yet been received by ZigChain |
960
+ | height | Block height at which this data was read |
477
961
 
478
- > “Out of these committed packets, which ones have not been received?”
962
+ > An empty `sequences` array means all queried packets (`53`, `54`, `71`) have already been received by ZigChain — no inbound delivery is pending.
479
963
 
480
- ---
964
+ ### `fetchUnreceivedAcks` vs `fetchUnreceivedPackets`
481
965
 
482
- ### Parameters
966
+ | Feature | fetchUnreceivedAcks | fetchUnreceivedPackets |
967
+ | --------- | ------------------------------------ | ------------------------------------ |
968
+ | Direction | Outbound (sent from ZigChain) | Inbound (sent to ZigChain) |
969
+ | Question | Which acks haven't come back yet? | Which packets haven't arrived yet? |
970
+ | Result | Sequences `[53, 54]` pending | Empty — all received |
483
971
 
484
- * **portId** The application port.
485
- * **channelId** – The IBC channel identifier.
486
- * **sequences** – List of packet sequence numbers to check.
487
-
488
- ---
972
+ ## When to Use
489
973
 
974
+ * Checking for packets in transit toward ZigChain
975
+ * Detecting dropped or stuck inbound IBC transfers
490
976
 
977
+ ---