@zuhaibnoor/zigchain-sdk 1.1.1 → 1.1.2
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/dist/consensus/ChainConsensusApi.d.ts +5 -0
- package/dist/consensus/ChainConsensusApi.d.ts.map +1 -1
- package/dist/consensus/ChainConsensusApi.js +16 -0
- package/dist/consensus/ChainConsensusApi.js.map +1 -1
- package/dist/consensus/types.d.ts +55 -0
- package/dist/consensus/types.d.ts.map +1 -1
- package/docs/consensus.md +600 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { NetworkEndpoints } from '../networks/endpoints.js';
|
|
2
|
+
import type { NodeInfoResponse, SyncingResponse, ValidatorSetResponse } from './types.js';
|
|
2
3
|
export declare class ChainConsensusApi {
|
|
3
4
|
private client;
|
|
4
5
|
constructor(endpoints: NetworkEndpoints);
|
|
@@ -8,5 +9,9 @@ export declare class ChainConsensusApi {
|
|
|
8
9
|
fetchConsensusParams(options?: {
|
|
9
10
|
height?: number;
|
|
10
11
|
}): Promise<import("./types.js").ConsensusParams>;
|
|
12
|
+
fetchNodeInfo(): Promise<NodeInfoResponse>;
|
|
13
|
+
fetchSyncing(): Promise<SyncingResponse>;
|
|
14
|
+
fetchLatestValidatorSets(): Promise<ValidatorSetResponse>;
|
|
15
|
+
fetchValidatorSetAt(height: number | string): Promise<ValidatorSetResponse>;
|
|
11
16
|
}
|
|
12
17
|
//# sourceMappingURL=ChainConsensusApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChainConsensusApi.d.ts","sourceRoot":"","sources":["../../src/consensus/ChainConsensusApi.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"ChainConsensusApi.d.ts","sourceRoot":"","sources":["../../src/consensus/ChainConsensusApi.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,KAAK,EAEV,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EAEpB,MAAM,YAAY,CAAA;AAEpB,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAY;gBAEd,SAAS,EAAE,gBAAgB;IAIvC;;OAEG;IACG,oBAAoB,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAclD,aAAa;IAKb,YAAY;IAKZ,wBAAwB;IAKxB,mBAAmB,CAAC,MAAM,EAAG,MAAM,GAAG,MAAM;CAKnD"}
|
|
@@ -14,5 +14,21 @@ export class ChainConsensusApi {
|
|
|
14
14
|
const data = await this.client.get('/cosmos/consensus/v1/params', headers);
|
|
15
15
|
return data.params;
|
|
16
16
|
}
|
|
17
|
+
async fetchNodeInfo() {
|
|
18
|
+
const node_info = await this.client.get(`/cosmos/base/tendermint/v1beta1/node_info`);
|
|
19
|
+
return node_info;
|
|
20
|
+
}
|
|
21
|
+
async fetchSyncing() {
|
|
22
|
+
const syncing = await this.client.get(`/cosmos/base/tendermint/v1beta1/syncing`);
|
|
23
|
+
return syncing;
|
|
24
|
+
}
|
|
25
|
+
async fetchLatestValidatorSets() {
|
|
26
|
+
const validators = await this.client.get(`/cosmos/base/tendermint/v1beta1/validatorsets/latest`);
|
|
27
|
+
return validators;
|
|
28
|
+
}
|
|
29
|
+
async fetchValidatorSetAt(height) {
|
|
30
|
+
const validators = await this.client.get(`/cosmos/base/tendermint/v1beta1/validatorsets/${height}`);
|
|
31
|
+
return validators;
|
|
32
|
+
}
|
|
17
33
|
}
|
|
18
34
|
//# sourceMappingURL=ChainConsensusApi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChainConsensusApi.js","sourceRoot":"","sources":["../../src/consensus/ChainConsensusApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"ChainConsensusApi.js","sourceRoot":"","sources":["../../src/consensus/ChainConsensusApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAU9C,MAAM,OAAO,iBAAiB;IACpB,MAAM,CAAY;IAE1B,YAAY,SAA2B;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC7C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,oBAAoB,CAAC,OAA6B;QACtD,MAAM,OAAO,GACX,OAAO,EAAE,MAAM,KAAK,SAAS;YAC3B,CAAC,CAAC,EAAE,uBAAuB,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACrD,CAAC,CAAC,SAAS,CAAA;QAEf,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAChC,6BAA6B,EAC7B,OAAO,CACR,CAAA;QAED,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAmB,2CAA2C,CAAC,CAAA;QACtG,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAkB,yCAAyC,CAAC,CAAA;QACjG,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,KAAK,CAAC,wBAAwB;QAC5B,MAAM,UAAU,GAAG,MAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAuB,sDAAsD,CAAC,CAAA;QACvH,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,MAAwB;QAChD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAuB,iDAAiD,MAAM,EAAE,CAAC,CAAA;QACzH,OAAO,UAAU,CAAA;IACnB,CAAC;CAEF"}
|
|
@@ -15,4 +15,59 @@ export interface ConsensusParams {
|
|
|
15
15
|
pub_key_types: string[];
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
+
export interface NodeInfoResponse {
|
|
19
|
+
application_version: {
|
|
20
|
+
app_name: string;
|
|
21
|
+
build_deps: [
|
|
22
|
+
{
|
|
23
|
+
path: string;
|
|
24
|
+
sum: string;
|
|
25
|
+
version: string;
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
build_tags: string;
|
|
29
|
+
cosmos_sdk_version: string;
|
|
30
|
+
git_commit: string;
|
|
31
|
+
go_version: string;
|
|
32
|
+
name: string;
|
|
33
|
+
version: string;
|
|
34
|
+
};
|
|
35
|
+
default_node_info: {
|
|
36
|
+
channels: string;
|
|
37
|
+
default_node_id: string;
|
|
38
|
+
listen_addr: string;
|
|
39
|
+
moniker: string;
|
|
40
|
+
network: string;
|
|
41
|
+
other: {
|
|
42
|
+
rpc_address: string;
|
|
43
|
+
tx_index: string;
|
|
44
|
+
};
|
|
45
|
+
protocol_version: {
|
|
46
|
+
app: string;
|
|
47
|
+
block: string;
|
|
48
|
+
p2p: string;
|
|
49
|
+
};
|
|
50
|
+
version: string;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export interface SyncingResponse {
|
|
54
|
+
syncing: boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface ValidatorSetResponse {
|
|
57
|
+
block_height: string;
|
|
58
|
+
pagination: {
|
|
59
|
+
next_key: string;
|
|
60
|
+
total: string;
|
|
61
|
+
};
|
|
62
|
+
validators: [
|
|
63
|
+
{
|
|
64
|
+
address: string;
|
|
65
|
+
proposer_priority: string;
|
|
66
|
+
pub_key: {
|
|
67
|
+
'@type': string;
|
|
68
|
+
};
|
|
69
|
+
voting_power: string;
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
}
|
|
18
73
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/consensus/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,eAAe,CAAA;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE;QACL,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,QAAQ,EAAE;QACR,kBAAkB,EAAE,MAAM,CAAA;QAC1B,gBAAgB,EAAE,MAAM,CAAA;QACxB,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,SAAS,EAAE;QACT,aAAa,EAAE,MAAM,EAAE,CAAA;KACxB,CAAA;CACF"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/consensus/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,eAAe,CAAA;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE;QACL,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,QAAQ,EAAE;QACR,kBAAkB,EAAE,MAAM,CAAA;QAC1B,gBAAgB,EAAE,MAAM,CAAA;QACxB,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,SAAS,EAAE;QACT,aAAa,EAAE,MAAM,EAAE,CAAA;KACxB,CAAA;CACF;AAED,MAAM,WAAW,gBAAgB;IAC/B,mBAAmB,EAAE;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,MAAM,CAAC;gBACb,GAAG,EAAE,MAAM,CAAC;gBACZ,OAAO,EAAE,MAAM,CAAA;aAChB;SACF,CAAC;QACF,UAAU,EAAE,MAAM,CAAC;QACnB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAA;KAChB,CAAC;IACF,iBAAiB,EAAE;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE;YACL,WAAW,EAAE,MAAM,CAAC;YACpB,QAAQ,EAAE,MAAM,CAAA;SACjB,CAAC;QACF,gBAAgB,EAAE;YAChB,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,EAAE,MAAM,CAAC;YACd,GAAG,EAAE,MAAM,CAAA;SACZ,CAAC;QACF,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;CACF;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAA;KACd,CAAC;IACF,UAAU,EAAE;QACV;YACE,OAAO,EAAE,MAAM,CAAC;YAChB,iBAAiB,EAAE,MAAM,CAAC;YAC1B,OAAO,EAAE;gBACP,OAAO,EAAE,MAAM,CAAA;aAChB,CAAC;YACF,YAAY,EAAE,MAAM,CAAA;SACrB;KACF,CAAA;CACF"}
|
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
# Consensus Module
|
|
2
|
+
|
|
3
|
+
## What is the Consensus Module?
|
|
4
|
+
|
|
5
|
+
The **Consensus module** allows you to query information about the blockchain's consensus mechanism and current validator set.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Important Terminology
|
|
10
|
+
|
|
11
|
+
Before documenting functions, let's define key terms.
|
|
12
|
+
|
|
13
|
+
### Consensus Parameters
|
|
14
|
+
|
|
15
|
+
**Consensus Parameters** are the rules that govern how blocks are created and validated on the blockchain.
|
|
16
|
+
|
|
17
|
+
They include:
|
|
18
|
+
* Maximum block size
|
|
19
|
+
* Maximum gas per block
|
|
20
|
+
* Evidence handling rules
|
|
21
|
+
* Validator public key types
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
### Validator Set
|
|
26
|
+
|
|
27
|
+
The **Validator Set** is the current list of validators responsible for creating blocks and reaching consensus.
|
|
28
|
+
|
|
29
|
+
Each validator has:
|
|
30
|
+
* **Address** – Consensus address (validator operator)
|
|
31
|
+
* **Public Key** – Key for signing blocks
|
|
32
|
+
* **Voting Power** – Stake-weighted power in consensus
|
|
33
|
+
* **Proposer Priority** – Used to rotate block proposers
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### Voting Power
|
|
38
|
+
|
|
39
|
+
**Voting Power** represents a validator's influence in reaching consensus.
|
|
40
|
+
|
|
41
|
+
Usually proportional to the validator's stake. Higher voting power means more influence on which blocks are canonical.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### Node Info
|
|
46
|
+
|
|
47
|
+
**Node Info** contains metadata about a node, including:
|
|
48
|
+
* Node ID
|
|
49
|
+
* Network name
|
|
50
|
+
* Application version
|
|
51
|
+
* Build information
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### Syncing Status
|
|
56
|
+
|
|
57
|
+
The **Syncing Status** indicates whether a node is catching up to the latest blocks.
|
|
58
|
+
|
|
59
|
+
* `true` – Node is syncing (behind)
|
|
60
|
+
* `false` – Node is caught up to the latest height
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
# Functions Documentation
|
|
65
|
+
|
|
66
|
+
Setup:
|
|
67
|
+
```ts
|
|
68
|
+
import {
|
|
69
|
+
ChainConsensusApi,
|
|
70
|
+
getNetworkEndpoints,
|
|
71
|
+
Network
|
|
72
|
+
} from '@zuhaibnoor/zigchain-sdk'
|
|
73
|
+
|
|
74
|
+
const endpoints = getNetworkEndpoints(Network.Testnet)
|
|
75
|
+
const consensusApi = new ChainConsensusApi(endpoints)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
# 1️⃣ fetchConsensusParams
|
|
81
|
+
|
|
82
|
+
## Method
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
async fetchConsensusParams(options?: { height?: number })
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## CLI Equivalent
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
zigchaind query consensus params
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Description
|
|
95
|
+
|
|
96
|
+
Fetches the **consensus parameters** that govern block production and validation.
|
|
97
|
+
|
|
98
|
+
Returns the current consensus rules including block size limits, gas limits, and evidence parameters.
|
|
99
|
+
|
|
100
|
+
Optionally query parameters at a specific historical height.
|
|
101
|
+
|
|
102
|
+
## Parameters
|
|
103
|
+
|
|
104
|
+
| Name | Type | Description |
|
|
105
|
+
| ---------- | ----------------------- | ----------------------------------- |
|
|
106
|
+
| options | object (optional) | Optional query options |
|
|
107
|
+
| height | number (optional) | Block height for historical query |
|
|
108
|
+
|
|
109
|
+
## Usage Example
|
|
110
|
+
|
|
111
|
+
### Current Consensus Parameters
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
const params = await consensusApi.fetchConsensusParams()
|
|
115
|
+
console.dir(params, { depth: null })
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Parameters at Specific Height
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
const paramsAtHeight = await consensusApi.fetchConsensusParams({
|
|
122
|
+
height: 4141776
|
|
123
|
+
})
|
|
124
|
+
console.dir(paramsAtHeight, { depth: null })
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Example Response
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"block": {
|
|
132
|
+
"max_bytes": "5000000",
|
|
133
|
+
"max_gas": "100000000"
|
|
134
|
+
},
|
|
135
|
+
"evidence": {
|
|
136
|
+
"max_age_num_blocks": "100000",
|
|
137
|
+
"max_age_duration": "172800s",
|
|
138
|
+
"max_bytes": "1048576"
|
|
139
|
+
},
|
|
140
|
+
"validator": {
|
|
141
|
+
"pub_key_types": ["ed25519"]
|
|
142
|
+
},
|
|
143
|
+
"version": {
|
|
144
|
+
"app": "0"
|
|
145
|
+
},
|
|
146
|
+
"abci": {
|
|
147
|
+
"vote_extensions_enable_height": "0"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Response Field Explanation
|
|
153
|
+
|
|
154
|
+
### `block`
|
|
155
|
+
|
|
156
|
+
Block production parameters.
|
|
157
|
+
|
|
158
|
+
| Field | Description |
|
|
159
|
+
| -------- | ---------------------------- |
|
|
160
|
+
| max_bytes | Maximum block size in bytes |
|
|
161
|
+
| max_gas | Maximum gas per block |
|
|
162
|
+
|
|
163
|
+
### `evidence`
|
|
164
|
+
|
|
165
|
+
Parameters for handling misbehavior evidence.
|
|
166
|
+
|
|
167
|
+
| Field | Description |
|
|
168
|
+
| ------------------ | -------------------------------------- |
|
|
169
|
+
| max_age_num_blocks | Max age of evidence in blocks |
|
|
170
|
+
| max_age_duration | Max age of evidence in time duration |
|
|
171
|
+
| max_bytes | Max evidence bytes per block |
|
|
172
|
+
|
|
173
|
+
### `validator`
|
|
174
|
+
|
|
175
|
+
Validator configuration.
|
|
176
|
+
|
|
177
|
+
| Field | Description |
|
|
178
|
+
| ------------ | ----------------------------- |
|
|
179
|
+
| pub_key_types | Allowed public key types |
|
|
180
|
+
|
|
181
|
+
In this example, only Ed25519 keys are allowed.
|
|
182
|
+
|
|
183
|
+
### `version`
|
|
184
|
+
|
|
185
|
+
Version parameters.
|
|
186
|
+
|
|
187
|
+
| Field | Description |
|
|
188
|
+
| ----- | ------------------------ |
|
|
189
|
+
| app | Application version |
|
|
190
|
+
|
|
191
|
+
### `abci`
|
|
192
|
+
|
|
193
|
+
ABCI (Application Blockchain Interface) parameters.
|
|
194
|
+
|
|
195
|
+
| Field | Description |
|
|
196
|
+
| -------------------------- | ------------------------------ |
|
|
197
|
+
| vote_extensions_enable_height | Height at which vote extensions enabled |
|
|
198
|
+
|
|
199
|
+
## Time Format
|
|
200
|
+
|
|
201
|
+
All time durations are in seconds with `s` suffix.
|
|
202
|
+
|
|
203
|
+
Example: `172800s` = 172800 seconds = 2 days
|
|
204
|
+
|
|
205
|
+
Convert to seconds: Remove the `s` and parse as number.
|
|
206
|
+
|
|
207
|
+
## When to Use
|
|
208
|
+
|
|
209
|
+
* Verifying consensus rules
|
|
210
|
+
* Understanding block constraints
|
|
211
|
+
* Monitoring governance parameter changes
|
|
212
|
+
* Building chain status dashboards
|
|
213
|
+
* Comparing parameters across networks
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
# 2️⃣ fetchNodeInfo
|
|
218
|
+
|
|
219
|
+
## Method
|
|
220
|
+
|
|
221
|
+
```ts
|
|
222
|
+
async fetchNodeInfo()
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## CLI Equivalent
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
zigchaind query consensus node-info
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Description
|
|
232
|
+
|
|
233
|
+
Fetches **information about the node** including software versions and configuration.
|
|
234
|
+
|
|
235
|
+
Returns:
|
|
236
|
+
* Node ID and network details
|
|
237
|
+
* Application version and git commit
|
|
238
|
+
* Dependencies and build information
|
|
239
|
+
|
|
240
|
+
## Parameters
|
|
241
|
+
|
|
242
|
+
None.
|
|
243
|
+
|
|
244
|
+
## Usage Example
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
const nodeInfo = await consensusApi.fetchNodeInfo()
|
|
248
|
+
console.dir(nodeInfo, { depth: null })
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Example Response
|
|
252
|
+
|
|
253
|
+
```json
|
|
254
|
+
{
|
|
255
|
+
"default_node_info": {
|
|
256
|
+
"protocol_version": {
|
|
257
|
+
"p2p": "8",
|
|
258
|
+
"block": "11",
|
|
259
|
+
"app": "0"
|
|
260
|
+
},
|
|
261
|
+
"default_node_id": "fafae5272113e3ff754b796e01790051526d1526",
|
|
262
|
+
"listen_addr": "0.0.0.0:26684",
|
|
263
|
+
"network": "zig-test-2",
|
|
264
|
+
"version": "0.38.19",
|
|
265
|
+
"channels": "QCAhIiMwOGBhAA==",
|
|
266
|
+
"moniker": "node-1",
|
|
267
|
+
"other": {
|
|
268
|
+
"tx_index": "on",
|
|
269
|
+
"rpc_address": "tcp://0.0.0.0:26657"
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
"application_version": {
|
|
273
|
+
"name": "zigchain",
|
|
274
|
+
"app_name": "zigchaind",
|
|
275
|
+
"version": "v3.0.0",
|
|
276
|
+
"git_commit": "d6bdf03a01b32c0fd16ac5564a48e9ab0e03c0c4",
|
|
277
|
+
"build_tags": "muslc,ledger",
|
|
278
|
+
"go_version": "go version go1.25.5 linux/amd64",
|
|
279
|
+
"cosmos_sdk_version": "v0.53.4",
|
|
280
|
+
"build_deps": [...]
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Response Field Explanation
|
|
286
|
+
|
|
287
|
+
### `default_node_info`
|
|
288
|
+
|
|
289
|
+
Network and node configuration.
|
|
290
|
+
|
|
291
|
+
| Field | Description |
|
|
292
|
+
| ------------------ | -------------------------------------- |
|
|
293
|
+
| protocol_version | P2P, block, and app protocol versions |
|
|
294
|
+
| default_node_id | Unique node identifier |
|
|
295
|
+
| listen_addr | P2P listen address |
|
|
296
|
+
| network | Network name (e.g., `zig-test-2`) |
|
|
297
|
+
| version | Tendermint version |
|
|
298
|
+
| moniker | Node name/identifier |
|
|
299
|
+
| other | Additional configuration |
|
|
300
|
+
|
|
301
|
+
### `protocol_version`
|
|
302
|
+
|
|
303
|
+
Protocol versions for different layers.
|
|
304
|
+
|
|
305
|
+
| Field | Description |
|
|
306
|
+
| ----- | --------------------------------- |
|
|
307
|
+
| p2p | Peer-to-peer protocol version |
|
|
308
|
+
| block | Block protocol version |
|
|
309
|
+
| app | Application protocol version |
|
|
310
|
+
|
|
311
|
+
### `application_version`
|
|
312
|
+
|
|
313
|
+
Application software information.
|
|
314
|
+
|
|
315
|
+
| Field | Description |
|
|
316
|
+
| ---------------------- | ------------------------------------ |
|
|
317
|
+
| name | Application name |
|
|
318
|
+
| app_name | Binary name (e.g., `zigchaind`) |
|
|
319
|
+
| version | Application version (e.g., `v3.0.0`) |
|
|
320
|
+
| git_commit | Git commit hash of build |
|
|
321
|
+
| build_tags | Build tags/features enabled |
|
|
322
|
+
| go_version | Go compiler version |
|
|
323
|
+
| cosmos_sdk_version | Cosmos SDK version |
|
|
324
|
+
| build_deps | Array of build dependencies |
|
|
325
|
+
|
|
326
|
+
### `other`
|
|
327
|
+
|
|
328
|
+
Additional node configuration.
|
|
329
|
+
|
|
330
|
+
| Field | Description |
|
|
331
|
+
| ----------- | ------------------------ |
|
|
332
|
+
| tx_index | Transaction indexing enabled |
|
|
333
|
+
| rpc_address | RPC endpoint address |
|
|
334
|
+
|
|
335
|
+
## When to Use
|
|
336
|
+
|
|
337
|
+
* Identifying node software versions
|
|
338
|
+
* Checking node configuration
|
|
339
|
+
* Verifying network name
|
|
340
|
+
* Building node status dashboards
|
|
341
|
+
* Monitoring software compatibility
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
# 3️⃣ fetchSyncing
|
|
346
|
+
|
|
347
|
+
## Method
|
|
348
|
+
|
|
349
|
+
```ts
|
|
350
|
+
async fetchSyncing()
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## CLI Equivalent
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
zigchaind query consensus syncing
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## Description
|
|
360
|
+
|
|
361
|
+
Checks if the **node is currently synchronizing** with the blockchain.
|
|
362
|
+
|
|
363
|
+
Returns:
|
|
364
|
+
* `true` – Node is behind and catching up
|
|
365
|
+
* `false` – Node is caught up to latest height
|
|
366
|
+
|
|
367
|
+
## Parameters
|
|
368
|
+
|
|
369
|
+
None.
|
|
370
|
+
|
|
371
|
+
## Usage Example
|
|
372
|
+
|
|
373
|
+
```ts
|
|
374
|
+
const syncStatus = await consensusApi.fetchSyncing()
|
|
375
|
+
console.dir(syncStatus, { depth: null })
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## Example Response
|
|
379
|
+
|
|
380
|
+
### Node Caught Up
|
|
381
|
+
|
|
382
|
+
```json
|
|
383
|
+
{
|
|
384
|
+
"syncing": false
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### Node Syncing
|
|
389
|
+
|
|
390
|
+
```json
|
|
391
|
+
{
|
|
392
|
+
"syncing": true
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
## Response Field Explanation
|
|
397
|
+
|
|
398
|
+
| Field | Description |
|
|
399
|
+
| ------- | --------------------- |
|
|
400
|
+
| syncing | Synchronization status |
|
|
401
|
+
|
|
402
|
+
## When to Use
|
|
403
|
+
|
|
404
|
+
* Health checks for nodes
|
|
405
|
+
* Determining if node is ready for queries
|
|
406
|
+
* Monitoring node participation
|
|
407
|
+
* Building node dashboards
|
|
408
|
+
* Waiting for nodes to catch up
|
|
409
|
+
|
|
410
|
+
---
|
|
411
|
+
|
|
412
|
+
# 4️⃣ fetchLatestValidatorSets
|
|
413
|
+
|
|
414
|
+
## Method
|
|
415
|
+
|
|
416
|
+
```ts
|
|
417
|
+
async fetchLatestValidatorSets()
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
## CLI Equivalent
|
|
421
|
+
|
|
422
|
+
```bash
|
|
423
|
+
zigchaind query consensus latest-validator-sets
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
## Description
|
|
427
|
+
|
|
428
|
+
Fetches the **current active validator set**.
|
|
429
|
+
|
|
430
|
+
Returns all validators currently participating in consensus with their voting power and keys.
|
|
431
|
+
|
|
432
|
+
## Parameters
|
|
433
|
+
|
|
434
|
+
None.
|
|
435
|
+
|
|
436
|
+
## Usage Example
|
|
437
|
+
|
|
438
|
+
```ts
|
|
439
|
+
const validators = await consensusApi.fetchLatestValidatorSets()
|
|
440
|
+
console.dir(validators, { depth: null })
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
## Example Response
|
|
444
|
+
|
|
445
|
+
```json
|
|
446
|
+
{
|
|
447
|
+
"block_height": "4649701",
|
|
448
|
+
"validators": [
|
|
449
|
+
{
|
|
450
|
+
"address": "zigvalcons15hcvyh2h0rrzrsswzu67s83z2v462rantszqnx",
|
|
451
|
+
"pub_key": {
|
|
452
|
+
"@type": "/cosmos.crypto.ed25519.PubKey",
|
|
453
|
+
"key": "f+akljJ8Y0dKwWz3bKkRN+RDz9EM+yA/j7Gre+Hn02c="
|
|
454
|
+
},
|
|
455
|
+
"voting_power": "25350159",
|
|
456
|
+
"proposer_priority": "13937913"
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
"address": "zigvalcons13atuu9t8ryjaq6a5a3twjc2nudh7l6uemvgmes",
|
|
460
|
+
"pub_key": {
|
|
461
|
+
"@type": "/cosmos.crypto.ed25519.PubKey",
|
|
462
|
+
"key": "SBjHwAbgG2ZfZtbBMJgcr+z+S/2BuPQZROVLnvS4QHM="
|
|
463
|
+
},
|
|
464
|
+
"voting_power": "25227820",
|
|
465
|
+
"proposer_priority": "-16758936"
|
|
466
|
+
}
|
|
467
|
+
],
|
|
468
|
+
"pagination": {
|
|
469
|
+
"next_key": null,
|
|
470
|
+
"total": "8"
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
## Response Field Explanation
|
|
476
|
+
|
|
477
|
+
### `block_height`
|
|
478
|
+
|
|
479
|
+
The block height at which this validator set is active.
|
|
480
|
+
|
|
481
|
+
### `validators`
|
|
482
|
+
|
|
483
|
+
Array of active validators.
|
|
484
|
+
|
|
485
|
+
Each validator contains:
|
|
486
|
+
|
|
487
|
+
| Field | Description |
|
|
488
|
+
| ----------------- | ---------------------------------- |
|
|
489
|
+
| address | Validator consensus address |
|
|
490
|
+
| pub_key | Public key for signing blocks |
|
|
491
|
+
| voting_power | Stake-weighted power in consensus |
|
|
492
|
+
| proposer_priority | Priority for block proposal rotation |
|
|
493
|
+
|
|
494
|
+
### `pub_key`
|
|
495
|
+
|
|
496
|
+
The validator's public key for cryptographic operations.
|
|
497
|
+
|
|
498
|
+
| Field | Description |
|
|
499
|
+
| ----- | ------------------------------ |
|
|
500
|
+
| @type | Key type (`/cosmos.crypto.ed25519.PubKey`) |
|
|
501
|
+
| key | Base64-encoded public key bytes |
|
|
502
|
+
|
|
503
|
+
### `voting_power`
|
|
504
|
+
|
|
505
|
+
The validator's influence in consensus, typically proportional to stake.
|
|
506
|
+
|
|
507
|
+
Higher values = more influence = more blocks proposed.
|
|
508
|
+
|
|
509
|
+
### `proposer_priority`
|
|
510
|
+
|
|
511
|
+
Score used to fairly rotate block proposals among validators.
|
|
512
|
+
|
|
513
|
+
Increases when a validator proposes, decreases as others propose.
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
## When to Use
|
|
517
|
+
|
|
518
|
+
* Monitoring active validator set
|
|
519
|
+
* Building explorer dashboards
|
|
520
|
+
* Validator set health monitoring
|
|
521
|
+
|
|
522
|
+
---
|
|
523
|
+
|
|
524
|
+
# 5️⃣ fetchValidatorSetAt
|
|
525
|
+
|
|
526
|
+
## Method
|
|
527
|
+
|
|
528
|
+
```ts
|
|
529
|
+
async fetchValidatorSetAt(height: number | string)
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
## CLI Equivalent
|
|
533
|
+
|
|
534
|
+
```bash
|
|
535
|
+
zigchaind query consensus validator-set <height>
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
## Description
|
|
539
|
+
|
|
540
|
+
Fetches the **validator set at a specific historical height**.
|
|
541
|
+
|
|
542
|
+
Allows you to see which validators were active at any point in the blockchain's history.
|
|
543
|
+
|
|
544
|
+
## Parameters
|
|
545
|
+
|
|
546
|
+
| Name | Type | Description |
|
|
547
|
+
| ------ | ----------------- | --------------------- |
|
|
548
|
+
| height | number \| string | Block height to query |
|
|
549
|
+
|
|
550
|
+
## Usage Example
|
|
551
|
+
|
|
552
|
+
```ts
|
|
553
|
+
const validatorsAtHeight = await consensusApi.fetchValidatorSetAt(4141776)
|
|
554
|
+
console.dir(validatorsAtHeight, { depth: null })
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
## Example Response
|
|
558
|
+
|
|
559
|
+
```json
|
|
560
|
+
{
|
|
561
|
+
"block_height": "4141776",
|
|
562
|
+
"validators": [
|
|
563
|
+
{
|
|
564
|
+
"address": "zigvalcons15hcvyh2h0rrzrsswzu67s83z2v462rantszqnx",
|
|
565
|
+
"pub_key": {
|
|
566
|
+
"@type": "/cosmos.crypto.ed25519.PubKey",
|
|
567
|
+
"key": "f+akljJ8Y0dKwWz3bKkRN+RDz9EM+yA/j7Gre+Hn02c="
|
|
568
|
+
},
|
|
569
|
+
"voting_power": "25346024",
|
|
570
|
+
"proposer_priority": "65554751"
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
"address": "zigvalcons13atuu9t8ryjaq6a5a3twjc2nudh7l6uemvgmes",
|
|
574
|
+
"pub_key": {
|
|
575
|
+
"@type": "/cosmos.crypto.ed25519.PubKey",
|
|
576
|
+
"key": "SBjHwAbgG2ZfZtbBMJgcr+z+S/2BuPQZROVLnvS4QHM="
|
|
577
|
+
},
|
|
578
|
+
"voting_power": "25227954",
|
|
579
|
+
"proposer_priority": "-2728799"
|
|
580
|
+
}
|
|
581
|
+
],
|
|
582
|
+
"pagination": {
|
|
583
|
+
"next_key": null,
|
|
584
|
+
"total": "7"
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
## Response Field Explanation
|
|
590
|
+
|
|
591
|
+
Same as `fetchLatestValidatorSets()` response.
|
|
592
|
+
|
|
593
|
+
The `block_height` field will reflect the queried height, and validator data will be the set at that historical point.
|
|
594
|
+
|
|
595
|
+
## When to Use
|
|
596
|
+
|
|
597
|
+
* Analyzing historical validator changes
|
|
598
|
+
* Investigating validator set transitions
|
|
599
|
+
|
|
600
|
+
---
|