@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.
- package/README.md +1 -1
- package/dist/auth/ChainAuthApi.d.ts +0 -3
- package/dist/auth/ChainAuthApi.d.ts.map +1 -1
- package/dist/auth/ChainAuthApi.js +0 -26
- package/dist/auth/ChainAuthApi.js.map +1 -1
- package/dist/bank/ChainBankApi.d.ts +0 -9
- package/dist/bank/ChainBankApi.d.ts.map +1 -1
- package/dist/bank/ChainBankApi.js +0 -18
- package/dist/bank/ChainBankApi.js.map +1 -1
- package/dist/circuit/ChainCircuitApi.d.ts.map +1 -1
- package/dist/circuit/ChainCircuitApi.js.map +1 -1
- package/dist/client/http.d.ts +1 -0
- package/dist/client/http.d.ts.map +1 -1
- package/dist/client/http.js +10 -0
- package/dist/client/http.js.map +1 -1
- package/dist/dex/ChainDexApi.d.ts.map +1 -1
- package/dist/dex/ChainDexApi.js.map +1 -1
- package/dist/distribution/ChainDistributionApi.d.ts +47 -0
- package/dist/distribution/ChainDistributionApi.d.ts.map +1 -0
- package/dist/distribution/ChainDistributionApi.js +74 -0
- package/dist/distribution/ChainDistributionApi.js.map +1 -0
- package/dist/distribution/types.d.ts +71 -0
- package/dist/distribution/types.d.ts.map +1 -0
- package/dist/distribution/types.js +2 -0
- package/dist/distribution/types.js.map +1 -0
- package/dist/evidence/ChainEvidenceApi.d.ts +15 -0
- package/dist/evidence/ChainEvidenceApi.d.ts.map +1 -0
- package/dist/evidence/ChainEvidenceApi.js +22 -0
- package/dist/evidence/ChainEvidenceApi.js.map +1 -0
- package/dist/evidence/types.d.ts +15 -0
- package/dist/evidence/types.d.ts.map +1 -0
- package/dist/evidence/types.js +2 -0
- package/dist/evidence/types.js.map +1 -0
- package/dist/feegrant/ChainFeegrantApi.d.ts +22 -0
- package/dist/feegrant/ChainFeegrantApi.d.ts.map +1 -0
- package/dist/feegrant/ChainFeegrantApi.js +32 -0
- package/dist/feegrant/ChainFeegrantApi.js.map +1 -0
- package/dist/feegrant/types.d.ts +17 -0
- package/dist/feegrant/types.d.ts.map +1 -0
- package/dist/feegrant/types.js +2 -0
- package/dist/feegrant/types.js.map +1 -0
- package/dist/ibc/ChainIbcApi.d.ts +55 -0
- package/dist/ibc/ChainIbcApi.d.ts.map +1 -0
- package/dist/ibc/ChainIbcApi.js +82 -0
- package/dist/ibc/ChainIbcApi.js.map +1 -0
- package/dist/ibc/ibcChannel/ChainIbcChannelApi.d.ts +55 -0
- package/dist/ibc/ibcChannel/ChainIbcChannelApi.d.ts.map +1 -0
- package/dist/ibc/ibcChannel/ChainIbcChannelApi.js +82 -0
- package/dist/ibc/ibcChannel/ChainIbcChannelApi.js.map +1 -0
- package/dist/ibc/ibcChannel/types.d.ts +106 -0
- package/dist/ibc/ibcChannel/types.d.ts.map +1 -0
- package/dist/ibc/ibcChannel/types.js +2 -0
- package/dist/ibc/ibcChannel/types.js.map +1 -0
- package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.d.ts +14 -0
- package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.d.ts.map +1 -0
- package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.js +38 -0
- package/dist/ibc/ibcChannelV2/ChainIbcChannelV2.js.map +1 -0
- package/dist/ibc/ibcChannelV2/types.d.ts +26 -0
- package/dist/ibc/ibcChannelV2/types.d.ts.map +1 -0
- package/dist/ibc/ibcChannelV2/types.js +3 -0
- package/dist/ibc/ibcChannelV2/types.js.map +1 -0
- package/dist/ibc/ibcClient/ChainIbcClientApi.d.ts +15 -0
- package/dist/ibc/ibcClient/ChainIbcClientApi.d.ts.map +1 -0
- package/dist/ibc/ibcClient/ChainIbcClientApi.js +39 -0
- package/dist/ibc/ibcClient/ChainIbcClientApi.js.map +1 -0
- package/dist/ibc/ibcClient/types.d.ts +53 -0
- package/dist/ibc/ibcClient/types.d.ts.map +1 -0
- package/dist/ibc/ibcClient/types.js +2 -0
- package/dist/ibc/ibcClient/types.js.map +1 -0
- package/dist/ibc/ibcConnection/ChainIbcConnectionApi.d.ts +11 -0
- package/dist/ibc/ibcConnection/ChainIbcConnectionApi.d.ts.map +1 -0
- package/dist/ibc/ibcConnection/ChainIbcConnectionApi.js +24 -0
- package/dist/ibc/ibcConnection/ChainIbcConnectionApi.js.map +1 -0
- package/dist/ibc/ibcConnection/types.d.ts +18 -0
- package/dist/ibc/ibcConnection/types.d.ts.map +1 -0
- package/dist/ibc/ibcConnection/types.js +2 -0
- package/dist/ibc/ibcConnection/types.js.map +1 -0
- package/dist/ibc/types.d.ts +106 -0
- package/dist/ibc/types.d.ts.map +1 -0
- package/dist/ibc/types.js +2 -0
- package/dist/ibc/types.js.map +1 -0
- package/dist/ibc-transfer/ChainIbcTransferApi.d.ts +12 -0
- package/dist/ibc-transfer/ChainIbcTransferApi.d.ts.map +1 -0
- package/dist/ibc-transfer/ChainIbcTransferApi.js +30 -0
- package/dist/ibc-transfer/ChainIbcTransferApi.js.map +1 -0
- package/dist/ibc-transfer/types.d.ts +26 -0
- package/dist/ibc-transfer/types.d.ts.map +1 -0
- package/dist/ibc-transfer/types.js +2 -0
- package/dist/ibc-transfer/types.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/dist/interchain-accounts/ChainInterChainAccApi.d.ts +9 -0
- package/dist/interchain-accounts/ChainInterChainAccApi.d.ts.map +1 -0
- package/dist/interchain-accounts/ChainInterChainAccApi.js +16 -0
- package/dist/interchain-accounts/ChainInterChainAccApi.js.map +1 -0
- package/dist/interchain-accounts/types.d.ts +12 -0
- package/dist/interchain-accounts/types.d.ts.map +1 -0
- package/dist/interchain-accounts/types.js +2 -0
- package/dist/interchain-accounts/types.js.map +1 -0
- package/dist/networks/endpoints.js +2 -2
- package/dist/networks/endpoints.js.map +1 -1
- package/dist/runtime/ChainRuntimeApi.d.ts +12 -0
- package/dist/runtime/ChainRuntimeApi.d.ts.map +1 -0
- package/dist/runtime/ChainRuntimeApi.js +16 -0
- package/dist/runtime/ChainRuntimeApi.js.map +1 -0
- package/dist/runtime/types.d.ts +4 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +2 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/staking/ChainStakingApi.d.ts +1 -5
- package/dist/staking/ChainStakingApi.d.ts.map +1 -1
- package/dist/staking/ChainStakingApi.js +9 -7
- package/dist/staking/ChainStakingApi.js.map +1 -1
- package/dist/tokenwrapper/ChainTokenWrapperApi.d.ts +19 -0
- package/dist/tokenwrapper/ChainTokenWrapperApi.d.ts.map +1 -0
- package/dist/tokenwrapper/ChainTokenWrapperApi.js +26 -0
- package/dist/tokenwrapper/ChainTokenWrapperApi.js.map +1 -0
- package/dist/tokenwrapper/types.d.ts +15 -0
- package/dist/tokenwrapper/types.d.ts.map +1 -0
- package/dist/tokenwrapper/types.js +2 -0
- package/dist/tokenwrapper/types.js.map +1 -0
- package/dist/txs/ChainTxsApi.d.ts +12 -0
- package/dist/txs/ChainTxsApi.d.ts.map +1 -0
- package/dist/txs/ChainTxsApi.js +17 -0
- package/dist/txs/ChainTxsApi.js.map +1 -0
- package/dist/txs/types.d.ts +22 -0
- package/dist/txs/types.d.ts.map +1 -0
- package/dist/txs/types.js +5 -0
- package/dist/txs/types.js.map +1 -0
- package/dist/upgrade/ChainUpgradeApi.d.ts +22 -0
- package/dist/upgrade/ChainUpgradeApi.d.ts.map +1 -0
- package/dist/upgrade/ChainUpgradeApi.js +40 -0
- package/dist/upgrade/ChainUpgradeApi.js.map +1 -0
- package/dist/upgrade/types.d.ts +24 -0
- package/dist/upgrade/types.d.ts.map +1 -0
- package/dist/upgrade/types.js +5 -0
- package/dist/upgrade/types.js.map +1 -0
- package/dist/validator-set/ChainCometValidator.d.ts +8 -0
- package/dist/validator-set/ChainCometValidator.d.ts.map +1 -0
- package/dist/validator-set/ChainCometValidator.js +15 -0
- package/dist/validator-set/ChainCometValidator.js.map +1 -0
- package/dist/validator-set/ChainValidator.d.ts +8 -0
- package/dist/validator-set/ChainValidator.d.ts.map +1 -0
- package/dist/validator-set/ChainValidator.js +15 -0
- package/dist/validator-set/ChainValidator.js.map +1 -0
- package/dist/validator-set/types.d.ts +18 -0
- package/dist/validator-set/types.d.ts.map +1 -0
- package/dist/validator-set/types.js +2 -0
- package/dist/validator-set/types.js.map +1 -0
- package/dist/wasm/ChainWasmApi.d.ts +57 -0
- package/dist/wasm/ChainWasmApi.d.ts.map +1 -0
- package/dist/wasm/ChainWasmApi.js +78 -0
- package/dist/wasm/ChainWasmApi.js.map +1 -0
- package/dist/wasm/types.d.ts +77 -0
- package/dist/wasm/types.d.ts.map +1 -0
- package/dist/wasm/types.js +2 -0
- package/dist/wasm/types.js.map +1 -0
- package/docs/auth.md +438 -72
- package/docs/bank.md +782 -123
- package/docs/block-results.md +328 -21
- package/docs/block.md +325 -38
- package/docs/circuit.md +164 -35
- package/docs/dex.md +313 -63
- package/docs/distribution.md +772 -0
- package/docs/evidence.md +194 -0
- package/docs/factory.md +308 -62
- package/docs/feegrant.md +206 -0
- package/docs/gov.md +364 -0
- package/docs/ibc/ibcChannel.md +977 -0
- package/docs/ibc/ibcClient.md +771 -0
- package/docs/ibc/ibcConnection.md +214 -0
- package/docs/ibc-transfer.md +463 -0
- package/docs/interchain-accounts.md +223 -0
- package/docs/mint.md +270 -0
- package/docs/runtime.md +120 -0
- package/docs/slashing.md +287 -0
- package/docs/staking.md +756 -0
- package/docs/tokenwrapper.md +294 -0
- package/docs/txs.md +447 -0
- package/docs/upgrade.md +356 -0
- package/docs/validator-set.md +177 -0
- package/docs/wasm.md +916 -0
- package/package.json +1 -1
package/docs/block.md
CHANGED
|
@@ -1,7 +1,87 @@
|
|
|
1
|
-
# Block
|
|
1
|
+
# Block
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
## What does this class do?
|
|
4
|
+
|
|
5
|
+
The **Block** provides access to **raw block data** on ZigChain.
|
|
6
|
+
|
|
7
|
+
Every block contains the transactions included in it, the header metadata that links it to the rest of the chain, the validator signatures that committed it, and evidence of any misbehaviour. This class lets you retrieve any of that data by height or fetch the current chain tip.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Important Terminology
|
|
12
|
+
|
|
13
|
+
### Block
|
|
14
|
+
|
|
15
|
+
A **block** is a sealed, immutable unit of the blockchain. Each block contains an ordered list of transactions, a header with metadata, validator commit signatures, and a link back to the previous block.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
### Block Height
|
|
20
|
+
|
|
21
|
+
The sequential position of a block in the chain, starting from `1`. Every new block increments the height by one.
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
height = 2990050
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### Block Header
|
|
30
|
+
|
|
31
|
+
Metadata that describes a block and cryptographically links it to the chain. Contains chain ID, timestamps, hashes, and the proposer address.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
### Block Hash
|
|
36
|
+
|
|
37
|
+
A cryptographic hash uniquely identifying a block. Represented as a Base64-encoded string in responses.
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
hash = 'r08gjOcW8lS6yGkwecQttOBbLiKP9gjBXOx6GO75B1I='
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### Proposer
|
|
46
|
+
|
|
47
|
+
The validator that was selected to propose (create) a given block. Identified by their consensus address.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
### Transactions (`txs`)
|
|
52
|
+
|
|
53
|
+
Raw Base64-encoded transaction data included in the block.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
### Last Commit
|
|
58
|
+
|
|
59
|
+
The set of validator signatures that committed the **previous block**. Each signature entry identifies the validator and confirms they voted for that block.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
### `block` vs `sdk_block`
|
|
64
|
+
|
|
65
|
+
The response contains two representations of the same block:
|
|
66
|
+
|
|
67
|
+
| Field | Description |
|
|
68
|
+
| ----------- | --------------------------------------------------------------------------- |
|
|
69
|
+
| `block` | Raw Tendermint/CometBFT block — proposer address is raw bytes (Base64) |
|
|
70
|
+
| `sdk_block` | Cosmos SDK-enhanced block — proposer address is a bech32 `zigvalcons` address |
|
|
71
|
+
|
|
72
|
+
For most use cases, `sdk_block` is easier to work with because addresses are human-readable.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### Block ID Flag
|
|
77
|
+
|
|
78
|
+
Each validator signature in `last_commit.signatures` includes a `block_id_flag` indicating how that validator voted:
|
|
79
|
+
|
|
80
|
+
| Flag | Meaning |
|
|
81
|
+
| ----------------------- | -------------------------------------------- |
|
|
82
|
+
| `BLOCK_ID_FLAG_COMMIT` | Validator signed and committed this block |
|
|
83
|
+
| `BLOCK_ID_FLAG_ABSENT` | Validator did not participate |
|
|
84
|
+
| `BLOCK_ID_FLAG_NIL` | Validator voted nil (no block) |
|
|
5
85
|
|
|
6
86
|
---
|
|
7
87
|
|
|
@@ -20,78 +100,285 @@ const blockApi = new ChainBlockApi(endpoints)
|
|
|
20
100
|
|
|
21
101
|
---
|
|
22
102
|
|
|
23
|
-
|
|
103
|
+
# 1️⃣ getBlockByHeight
|
|
104
|
+
|
|
105
|
+
## Method
|
|
24
106
|
|
|
25
|
-
|
|
26
|
-
|
|
107
|
+
```ts
|
|
108
|
+
async getBlockByHeight(height: number, atHeight?: number)
|
|
109
|
+
```
|
|
27
110
|
|
|
28
|
-
|
|
111
|
+
## CLI Equivalent
|
|
29
112
|
|
|
30
113
|
```bash
|
|
31
|
-
zigchaind query block
|
|
32
|
-
zigchaind query block --height <H>
|
|
114
|
+
zigchaind query block --type=height <height>
|
|
115
|
+
zigchaind query block --type=height <height> --height <H>
|
|
33
116
|
```
|
|
34
117
|
|
|
35
|
-
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Description
|
|
121
|
+
|
|
122
|
+
Fetches the **full block data for a specific block height**.
|
|
123
|
+
|
|
124
|
+
Returns the block header, all raw transactions included in the block, validator commit signatures, and evidence. The response includes both the raw Tendermint representation (`block`) and the Cosmos SDK-enhanced representation (`sdk_block`) with human-readable addresses.
|
|
125
|
+
|
|
126
|
+
The optional `atHeight` parameter allows querying this block as seen from a specific historical chain state — useful for advanced historical state comparisons.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Parameters
|
|
131
|
+
|
|
132
|
+
| Name | Type | Required | Description |
|
|
133
|
+
| -------- | ------ | -------- | ------------------------------------------------------------------------------------ |
|
|
134
|
+
| height | number | ✅ Yes | The block height to fetch |
|
|
135
|
+
| atHeight | number | ❌ No | Query the block from this historical chain state. Omit for latest state. |
|
|
136
|
+
|
|
137
|
+
> ⚠️ Using `atHeight` may fail if the node has pruned state at that height.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Usage Example
|
|
142
|
+
|
|
143
|
+
**Fetch a specific block:**
|
|
36
144
|
|
|
37
145
|
```ts
|
|
38
|
-
|
|
146
|
+
const block = await blockApi.getBlockByHeight(2990050)
|
|
147
|
+
console.dir(block, { depth: null })
|
|
39
148
|
```
|
|
40
149
|
|
|
41
|
-
**
|
|
150
|
+
**Fetch a block as seen from a historical chain state:**
|
|
42
151
|
|
|
43
152
|
```ts
|
|
44
|
-
const
|
|
45
|
-
console.
|
|
153
|
+
const block = await blockApi.getBlockByHeight(2990050, 3000000)
|
|
154
|
+
console.dir(block, { depth: null })
|
|
46
155
|
```
|
|
47
156
|
|
|
48
|
-
|
|
157
|
+
## Example Response
|
|
49
158
|
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"block_id": {
|
|
162
|
+
"hash": "r08gjOcW8lS6yGkwecQttOBbLiKP9gjBXOx6GO75B1I=",
|
|
163
|
+
"part_set_header": {
|
|
164
|
+
"total": 1,
|
|
165
|
+
"hash": "Bg/0BUwDfIUGfmmzD4aPGEoB9UdkY4JIRnWe8P8t+Hc="
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
"block": {
|
|
169
|
+
"header": {
|
|
170
|
+
"version": { "block": "11", "app": "0" },
|
|
171
|
+
"chain_id": "zig-test-2",
|
|
172
|
+
"height": "2990050",
|
|
173
|
+
"time": "2025-11-08T22:46:27.230010252Z",
|
|
174
|
+
"proposer_address": "j1fOFWcZJdBrtOxW6WFT42/v65k="
|
|
175
|
+
},
|
|
176
|
+
"data": {
|
|
177
|
+
"txs": [
|
|
178
|
+
"CvADCtYDCiQvY29zbXdhc20ud2FzbS52MS5Nc2dFeGVjdXRlQ29udHJhY3QS..."
|
|
179
|
+
]
|
|
180
|
+
},
|
|
181
|
+
"evidence": { "evidence": [] },
|
|
182
|
+
"last_commit": {
|
|
183
|
+
"height": "2990049",
|
|
184
|
+
"round": 0,
|
|
185
|
+
"signatures": [
|
|
186
|
+
{
|
|
187
|
+
"block_id_flag": "BLOCK_ID_FLAG_COMMIT",
|
|
188
|
+
"validator_address": "pfDCXVd4xiHCDhc16B4iUyulD7M=",
|
|
189
|
+
"timestamp": "2025-11-08T22:46:27.230010252Z",
|
|
190
|
+
"signature": "R9qDAUn+aLgeZ0l5fAc2..."
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
"sdk_block": {
|
|
196
|
+
"header": {
|
|
197
|
+
"chain_id": "zig-test-2",
|
|
198
|
+
"height": "2990050",
|
|
199
|
+
"time": "2025-11-08T22:46:27.230010252Z",
|
|
200
|
+
"proposer_address": "zigvalcons13atuu9t8ryjaq6a5a3twjc2nudh7l6uemvgmes"
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
53
204
|
```
|
|
54
205
|
|
|
206
|
+
## Response Field Explanation
|
|
207
|
+
|
|
208
|
+
### `block_id`
|
|
209
|
+
|
|
210
|
+
| Field | Description |
|
|
211
|
+
| ------------------------ | ---------------------------------------------------- |
|
|
212
|
+
| hash | Base64-encoded hash uniquely identifying this block |
|
|
213
|
+
| part_set_header.total | Number of block parts (always `1` for normal blocks) |
|
|
214
|
+
| part_set_header.hash | Hash of the block part set |
|
|
215
|
+
|
|
216
|
+
### `block.header` / `sdk_block.header`
|
|
217
|
+
|
|
218
|
+
| Field | Description |
|
|
219
|
+
| -------------------- | --------------------------------------------------------------------- |
|
|
220
|
+
| version.block | CometBFT protocol version |
|
|
221
|
+
| chain_id | Network identifier (e.g. `zig-test-2`) |
|
|
222
|
+
| height | This block's height |
|
|
223
|
+
| time | Timestamp when the block was committed |
|
|
224
|
+
| last_block_id.hash | Hash of the previous block — links the chain together |
|
|
225
|
+
| last_commit_hash | Hash of the previous block's commit signatures |
|
|
226
|
+
| data_hash | Hash of the transactions in this block |
|
|
227
|
+
| validators_hash | Hash of the current validator set |
|
|
228
|
+
| next_validators_hash | Hash of the next block's validator set |
|
|
229
|
+
| app_hash | Application state hash after all transactions were applied |
|
|
230
|
+
| last_results_hash | Hash of the previous block's transaction results |
|
|
231
|
+
| evidence_hash | Hash of any misbehaviour evidence included in this block |
|
|
232
|
+
| proposer_address | In `block`: raw Base64. In `sdk_block`: bech32 `zigvalcons` address |
|
|
233
|
+
|
|
234
|
+
### `block.data`
|
|
235
|
+
|
|
236
|
+
| Field | Description |
|
|
237
|
+
| ----- | -------------------------------------------------------------------- |
|
|
238
|
+
| txs | Array of raw Base64-encoded transactions included in this block |
|
|
239
|
+
|
|
240
|
+
> An empty `txs` array means the block contained no transactions (an empty block).
|
|
241
|
+
|
|
242
|
+
### `block.last_commit`
|
|
243
|
+
|
|
244
|
+
| Field | Description |
|
|
245
|
+
| ---------- | -------------------------------------------------------- |
|
|
246
|
+
| height | Height of the block this commit finalised (current - 1) |
|
|
247
|
+
| round | Consensus round in which this block was committed |
|
|
248
|
+
| block_id | Hash reference to the previous block |
|
|
249
|
+
| signatures | Array of validator commit signatures |
|
|
250
|
+
|
|
251
|
+
Each signature entry:
|
|
252
|
+
|
|
253
|
+
| Field | Description |
|
|
254
|
+
| ----------------- | ------------------------------------------------------- |
|
|
255
|
+
| block_id_flag | Validator's vote type (`COMMIT`, `ABSENT`, or `NIL`) |
|
|
256
|
+
| validator_address | Base64-encoded validator consensus address |
|
|
257
|
+
| timestamp | When the validator signed |
|
|
258
|
+
| signature | Base64-encoded cryptographic signature |
|
|
259
|
+
|
|
260
|
+
## When to Use
|
|
261
|
+
|
|
262
|
+
* Fetching full block contents for a known height
|
|
263
|
+
* Verifying which transactions were included in a block
|
|
264
|
+
* Checking which validators signed a specific block
|
|
265
|
+
* Building block explorer block detail pages
|
|
266
|
+
* Auditing chain state at a specific point in time
|
|
267
|
+
|
|
55
268
|
---
|
|
56
269
|
|
|
57
|
-
|
|
270
|
+
# 2️⃣ getLatestBlock
|
|
271
|
+
|
|
272
|
+
## Method
|
|
58
273
|
|
|
59
|
-
|
|
60
|
-
|
|
274
|
+
```ts
|
|
275
|
+
async getLatestBlock(atHeight?: number)
|
|
276
|
+
```
|
|
61
277
|
|
|
62
|
-
|
|
278
|
+
## CLI Equivalent
|
|
63
279
|
|
|
64
280
|
```bash
|
|
65
|
-
zigchaind query block
|
|
66
|
-
zigchaind query block --
|
|
281
|
+
zigchaind query block
|
|
282
|
+
zigchaind query block --height <H>
|
|
67
283
|
```
|
|
68
284
|
|
|
69
|
-
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Description
|
|
288
|
+
|
|
289
|
+
Fetches the **most recently committed block** on the chain.
|
|
290
|
+
|
|
291
|
+
This is the equivalent of checking the current chain tip — it tells you the latest block height, when it was produced, how many transactions it contained, and which validator proposed it.
|
|
292
|
+
|
|
293
|
+
The optional `atHeight` parameter is an advanced option that queries the latest block as seen from a specific historical chain state.
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Parameters
|
|
298
|
+
|
|
299
|
+
| Name | Type | Required | Description |
|
|
300
|
+
| -------- | ------ | -------- | ---------------------------------------------------------------------------- |
|
|
301
|
+
| atHeight | number | ❌ No | Query from this historical chain state. Omit to query current latest block. |
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Usage Example
|
|
306
|
+
|
|
307
|
+
**Fetch the current latest block:**
|
|
70
308
|
|
|
71
309
|
```ts
|
|
72
|
-
|
|
310
|
+
const latestBlock = await blockApi.getLatestBlock()
|
|
311
|
+
console.dir(latestBlock, { depth: null })
|
|
73
312
|
```
|
|
74
313
|
|
|
75
|
-
**
|
|
314
|
+
**Fetch the latest block as seen from a historical state:**
|
|
76
315
|
|
|
77
316
|
```ts
|
|
78
|
-
const
|
|
79
|
-
console.
|
|
317
|
+
const latestAtHeight = await blockApi.getLatestBlock(3000000)
|
|
318
|
+
console.dir(latestAtHeight, { depth: null })
|
|
80
319
|
```
|
|
81
320
|
|
|
82
|
-
|
|
321
|
+
## Example Response
|
|
83
322
|
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
|
|
323
|
+
```json
|
|
324
|
+
{
|
|
325
|
+
"block_id": {
|
|
326
|
+
"hash": "mDilLWqtCONHxux337yRYE8VgZN84E/2I4OQ2av0ysA=",
|
|
327
|
+
"part_set_header": { "total": 1, "hash": "X3COeE3KT8GuDahnnLUXJdabG++b68n+ELxm3OJ1P1g=" }
|
|
328
|
+
},
|
|
329
|
+
"block": {
|
|
330
|
+
"header": {
|
|
331
|
+
"chain_id": "zig-test-2",
|
|
332
|
+
"height": "4600308",
|
|
333
|
+
"time": "2026-02-21T05:56:32.495366040Z",
|
|
334
|
+
"proposer_address": "kf+/IYvD2VICszA7kymoXAyX+y4="
|
|
335
|
+
},
|
|
336
|
+
"data": { "txs": [] },
|
|
337
|
+
"evidence": { "evidence": [] },
|
|
338
|
+
"last_commit": {
|
|
339
|
+
"height": "4600307",
|
|
340
|
+
"round": 0,
|
|
341
|
+
"signatures": [
|
|
342
|
+
{
|
|
343
|
+
"block_id_flag": "BLOCK_ID_FLAG_COMMIT",
|
|
344
|
+
"validator_address": "pfDCXVd4xiHCDhc16B4iUyulD7M=",
|
|
345
|
+
"timestamp": "2026-02-21T05:56:32.495335987Z",
|
|
346
|
+
"signature": "YXHcv+uwO2/qPktnHfSWjCnQ6CU4..."
|
|
347
|
+
}
|
|
348
|
+
]
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
"sdk_block": {
|
|
352
|
+
"header": {
|
|
353
|
+
"chain_id": "zig-test-2",
|
|
354
|
+
"height": "4600308",
|
|
355
|
+
"time": "2026-02-21T05:56:32.495366040Z",
|
|
356
|
+
"proposer_address": "zigvalcons1j8lm7gvtc0v4yq4nxqaex2dgtsxf07ewjvh3rh"
|
|
357
|
+
},
|
|
358
|
+
"data": { "txs": [] }
|
|
359
|
+
}
|
|
360
|
+
}
|
|
87
361
|
```
|
|
88
362
|
|
|
89
|
-
|
|
363
|
+
The response structure is identical to `getBlockByHeight` — refer to that section for the full field-by-field breakdown.
|
|
364
|
+
|
|
365
|
+
### Quick Reads from the Latest Block
|
|
366
|
+
|
|
367
|
+
Here are the most commonly needed values and where to find them:
|
|
368
|
+
|
|
369
|
+
| Information needed | Field path |
|
|
370
|
+
| --------------------------- | --------------------------------------- |
|
|
371
|
+
| Current block height | `sdk_block.header.height` |
|
|
372
|
+
| Block timestamp | `sdk_block.header.time` |
|
|
373
|
+
| Proposing validator address | `sdk_block.header.proposer_address` |
|
|
374
|
+
| Number of transactions | `sdk_block.data.txs.length` |
|
|
375
|
+
| Chain ID | `sdk_block.header.chain_id` |
|
|
90
376
|
|
|
91
|
-
##
|
|
377
|
+
## When to Use
|
|
92
378
|
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
379
|
+
* Getting the current block height and chain tip
|
|
380
|
+
* Checking whether the chain is live and producing blocks
|
|
381
|
+
* Syncing an indexer to the latest state
|
|
382
|
+
* Displaying live block information in dashboards or explorers
|
|
96
383
|
|
|
97
384
|
---
|
package/docs/circuit.md
CHANGED
|
@@ -1,7 +1,50 @@
|
|
|
1
1
|
# Circuit Module
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
## What is the Circuit Module?
|
|
4
|
+
|
|
5
|
+
The **Circuit module** provides a **transaction permission and circuit breaker** system for ZigChain.
|
|
6
|
+
|
|
7
|
+
It allows designated super-admin accounts to selectively disable specific message types on the chain — acting as an emergency brake. This is a governance and safety mechanism, not something that affects normal users under typical chain operation.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Important Terminology
|
|
12
|
+
|
|
13
|
+
### Circuit Breaker
|
|
14
|
+
|
|
15
|
+
A **circuit breaker** is a safety mechanism that allows authorized accounts to disable specific transaction types on the chain without requiring a full governance vote. This is used in emergency situations — for example, if a vulnerability is discovered in a particular module.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
### Permission Level
|
|
20
|
+
|
|
21
|
+
Each account in the circuit module is assigned a **permission level** that defines what authority they have over circuit controls.
|
|
22
|
+
|
|
23
|
+
| Level | Description |
|
|
24
|
+
| ------------------- | --------------------------------------------------------------------------- |
|
|
25
|
+
| `LEVEL_NONE_UNSPECIFIED` | No circuit permissions — standard account |
|
|
26
|
+
| `LEVEL_SOME_MSGS` | Can disable a specific limited set of message types only |
|
|
27
|
+
| `LEVEL_ALL_MSGS` | Can disable any message type on the chain |
|
|
28
|
+
| `LEVEL_SUPER_ADMIN` | Full control — can disable messages and grant/revoke permissions to others |
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
### Limit Type URLs
|
|
33
|
+
|
|
34
|
+
When a permission level is `LEVEL_SOME_MSGS`, the `limit_type_urls` field specifies exactly which message types that account is authorized to circuit-break.
|
|
35
|
+
|
|
36
|
+
An empty `limit_type_urls` combined with `LEVEL_SUPER_ADMIN` means the account has **unrestricted** circuit breaker authority — no specific limits apply.
|
|
37
|
+
|
|
38
|
+
Example of a type URL:
|
|
39
|
+
```
|
|
40
|
+
/cosmos.bank.v1beta1.MsgSend
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### Disabled List
|
|
46
|
+
|
|
47
|
+
The set of message type URLs that are currently disabled (circuit-broken) on the chain. Any transaction containing a disabled message type will be rejected until the circuit is reset.
|
|
5
48
|
|
|
6
49
|
---
|
|
7
50
|
|
|
@@ -16,78 +59,164 @@ import {
|
|
|
16
59
|
|
|
17
60
|
const endpoints = getNetworkEndpoints(Network.Testnet)
|
|
18
61
|
const circuitApi = new ChainCircuitApi(endpoints)
|
|
62
|
+
|
|
63
|
+
const address = 'zig15yk64u7zc9g9k2yr2wmzeva5qgwxps6y8c2amk'
|
|
19
64
|
```
|
|
20
65
|
|
|
21
66
|
---
|
|
22
67
|
|
|
23
|
-
|
|
68
|
+
# 1️⃣ getAccountPermissions
|
|
24
69
|
|
|
25
|
-
|
|
70
|
+
## Method
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
async getAccountPermissions(address: string)
|
|
74
|
+
```
|
|
26
75
|
|
|
27
|
-
|
|
76
|
+
## CLI Equivalent
|
|
28
77
|
|
|
29
78
|
```bash
|
|
30
79
|
zigchaind query circuit account <address>
|
|
31
80
|
```
|
|
32
81
|
|
|
33
|
-
|
|
82
|
+
## Description
|
|
83
|
+
|
|
84
|
+
Fetches the **circuit breaker permissions** assigned to a specific account.
|
|
85
|
+
|
|
86
|
+
This tells you what level of circuit authority an account holds and, if applicable, which message types they are restricted to controlling. Most regular accounts will have no circuit permissions at all — only specifically designated addresses will appear in the circuit module with elevated levels.
|
|
87
|
+
|
|
88
|
+
## Parameters
|
|
89
|
+
|
|
90
|
+
| Name | Type | Description |
|
|
91
|
+
| ------- | ------ | ----------------------------------------------------- |
|
|
92
|
+
| address | string | Bech32 address of the account to query permissions for |
|
|
93
|
+
|
|
94
|
+
## Usage Example
|
|
34
95
|
|
|
35
96
|
```ts
|
|
36
|
-
getAccountPermissions(address
|
|
97
|
+
const account = await circuitApi.getAccountPermissions(address)
|
|
98
|
+
console.dir(account, { depth: null })
|
|
37
99
|
```
|
|
38
100
|
|
|
39
|
-
|
|
101
|
+
## Example Response
|
|
40
102
|
|
|
41
|
-
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"permission": {
|
|
106
|
+
"level": "LEVEL_SUPER_ADMIN",
|
|
107
|
+
"limit_type_urls": []
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
42
111
|
|
|
43
|
-
|
|
112
|
+
## Response Field Explanation
|
|
44
113
|
|
|
45
|
-
|
|
114
|
+
### `permission`
|
|
46
115
|
|
|
47
|
-
|
|
116
|
+
| Field | Description |
|
|
117
|
+
| ---------------- | --------------------------------------------------------------------------------- |
|
|
118
|
+
| level | Permission level assigned to this account |
|
|
119
|
+
| limit_type_urls | Specific message type URLs this account can circuit-break. Empty if unrestricted |
|
|
48
120
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
121
|
+
### Permission Level Values
|
|
122
|
+
|
|
123
|
+
| Value | Meaning |
|
|
124
|
+
| ------------------------ | -------------------------------------------------------------------- |
|
|
125
|
+
| `LEVEL_NONE_UNSPECIFIED` | No circuit permissions |
|
|
126
|
+
| `LEVEL_SOME_MSGS` | Can only circuit-break the specific types listed in `limit_type_urls` |
|
|
127
|
+
| `LEVEL_ALL_MSGS` | Can circuit-break any message type |
|
|
128
|
+
| `LEVEL_SUPER_ADMIN` | Full authority — can circuit-break messages and manage permissions |
|
|
129
|
+
|
|
130
|
+
> In the example above, `LEVEL_SUPER_ADMIN` with an empty `limit_type_urls` means this account has unrestricted circuit breaker authority over the entire chain.
|
|
131
|
+
|
|
132
|
+
## When to Use
|
|
133
|
+
|
|
134
|
+
* Verifying whether a specific address holds circuit breaker authority
|
|
135
|
+
* Auditing which accounts can perform emergency interventions
|
|
136
|
+
* Security reviews of chain admin key holders
|
|
137
|
+
* Building governance monitoring tools
|
|
55
138
|
|
|
56
139
|
---
|
|
57
140
|
|
|
58
|
-
|
|
141
|
+
# 2️⃣ getAllAccountPermissions
|
|
142
|
+
|
|
143
|
+
## Method
|
|
59
144
|
|
|
60
|
-
|
|
145
|
+
```ts
|
|
146
|
+
async getAllAccountPermissions()
|
|
147
|
+
```
|
|
61
148
|
|
|
62
|
-
|
|
149
|
+
## CLI Equivalent
|
|
63
150
|
|
|
64
151
|
```bash
|
|
65
152
|
zigchaind query circuit accounts
|
|
66
153
|
```
|
|
67
154
|
|
|
68
|
-
|
|
155
|
+
## Description
|
|
69
156
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
157
|
+
Fetches **all accounts** that have been assigned circuit breaker permissions on the chain.
|
|
158
|
+
|
|
159
|
+
On ZigChain testnet, only one account currently holds circuit permissions (`LEVEL_SUPER_ADMIN`). This reflects the typical setup where circuit authority is granted to a small number of trusted admin addresses for emergency use.
|
|
73
160
|
|
|
74
|
-
|
|
161
|
+
## Parameters
|
|
75
162
|
|
|
76
|
-
|
|
163
|
+
None.
|
|
77
164
|
|
|
78
|
-
|
|
165
|
+
## Usage Example
|
|
79
166
|
|
|
80
167
|
```ts
|
|
81
|
-
const
|
|
82
|
-
console.
|
|
83
|
-
console.dir(allPermissions, { depth: null })
|
|
168
|
+
const accounts = await circuitApi.getAllAccountPermissions()
|
|
169
|
+
console.dir(accounts, { depth: null })
|
|
84
170
|
```
|
|
85
171
|
|
|
86
|
-
|
|
172
|
+
## Example Response
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"accounts": [
|
|
177
|
+
{
|
|
178
|
+
"address": "zig15yk64u7zc9g9k2yr2wmzeva5qgwxps6y8c2amk",
|
|
179
|
+
"permissions": {
|
|
180
|
+
"level": "LEVEL_SUPER_ADMIN",
|
|
181
|
+
"limit_type_urls": []
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
],
|
|
185
|
+
"pagination": {
|
|
186
|
+
"next_key": null,
|
|
187
|
+
"total": "1"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Response Field Explanation
|
|
87
193
|
|
|
88
|
-
|
|
194
|
+
### `accounts`
|
|
89
195
|
|
|
90
|
-
|
|
91
|
-
* The `getAllAccountPermissions` method may return large datasets if many accounts are restricted.
|
|
196
|
+
Array of all accounts holding circuit breaker permissions.
|
|
92
197
|
|
|
198
|
+
Each entry contains:
|
|
93
199
|
|
|
200
|
+
| Field | Description |
|
|
201
|
+
| --------------------------- | ------------------------------------------------------------------------ |
|
|
202
|
+
| address | Bech32 address of the account with circuit permissions |
|
|
203
|
+
| permissions.level | Permission level assigned to this account |
|
|
204
|
+
| permissions.limit_type_urls | Message types this account can control. Empty if unrestricted |
|
|
205
|
+
|
|
206
|
+
### `pagination`
|
|
207
|
+
|
|
208
|
+
| Field | Description |
|
|
209
|
+
| -------- | -------------------------------------------------------------------- |
|
|
210
|
+
| next_key | Cursor for next page. `null` if all results are returned |
|
|
211
|
+
| total | Total number of accounts with circuit permissions on the chain |
|
|
212
|
+
|
|
213
|
+
> On ZigChain testnet, `total` is `"1"` — only one super admin account exists. A healthy, normally-operating chain will typically have a very small number of circuit-permissioned accounts.
|
|
214
|
+
|
|
215
|
+
## When to Use
|
|
216
|
+
|
|
217
|
+
* Full audit of all accounts with emergency chain intervention authority
|
|
218
|
+
* Verifying the complete set of circuit admins
|
|
219
|
+
* Chain governance and security dashboards
|
|
220
|
+
* Monitoring for unexpected changes to the circuit permission list
|
|
221
|
+
|
|
222
|
+
---
|