@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.
- package/README.md +1 -1
- package/dist/circuit/ChainCircuitApi.d.ts.map +1 -1
- package/dist/circuit/ChainCircuitApi.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.map +1 -1
- package/dist/distribution/ChainDistributionApi.js +0 -1
- package/dist/distribution/ChainDistributionApi.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- 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/upgrade/ChainUpgradeApi.d.ts.map +1 -1
- 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/docs/block.md +325 -38
- package/docs/circuit.md +164 -35
- package/docs/dex.md +313 -63
- package/docs/distribution.md +664 -93
- package/docs/evidence.md +117 -122
- package/docs/factory.md +308 -62
- package/docs/gov.md +268 -70
- package/docs/ibc/ibcChannel.md +736 -249
- package/docs/ibc/ibcClient.md +608 -139
- package/docs/ibc-transfer.md +349 -90
- package/docs/interchain-accounts.md +151 -48
- package/docs/mint.md +173 -36
- package/docs/runtime.md +81 -42
- package/docs/slashing.md +209 -61
- package/docs/staking.md +534 -411
- package/docs/tokenwrapper.md +221 -64
- package/docs/txs.md +447 -0
- package/docs/upgrade.md +281 -58
- package/docs/validator-set.md +177 -0
- package/package.json +1 -1
- package/docs/comet-validator-set.md +0 -70
package/docs/distribution.md
CHANGED
|
@@ -1,201 +1,772 @@
|
|
|
1
1
|
# Distribution Module
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
It manages validator commissions, delegator rewards, community pool funds, and distribution-related parameters.
|
|
3
|
+
## What is the Distribution Module?
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
The **Distribution module** is a core Cosmos SDK module responsible for **collecting and distributing staking rewards** on ZigChain.
|
|
6
|
+
|
|
7
|
+
Every block, newly minted tokens and transaction fees flow through this module. It handles splitting rewards between validators (as commission) and delegators (as staking rewards), maintains the community pool, and tracks outstanding and withdrawn amounts for every participant.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Important Terminology
|
|
12
|
+
|
|
13
|
+
### Staking Rewards
|
|
14
|
+
|
|
15
|
+
When you delegate tokens to a validator, you earn a share of the block rewards proportional to your stake. These accumulate over time and must be explicitly withdrawn.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
### Validator Commission
|
|
20
|
+
|
|
21
|
+
A **commission** is the percentage of delegator rewards that a validator keeps for themselves as payment for running the node. The remaining portion flows to delegators.
|
|
22
|
+
|
|
23
|
+
Commission accumulates continuously and is tracked separately from delegator rewards.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
### Community Pool
|
|
28
|
+
|
|
29
|
+
A portion of every block reward (defined by `community_tax`) is sent to the **community pool** — a shared on-chain treasury. These funds can only be spent via governance proposals.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
### Withdraw Address
|
|
34
|
+
|
|
35
|
+
By default, a delegator's rewards are sent to their own address when withdrawn. A delegator can optionally configure a **custom withdraw address** — a different address where rewards will be sent instead.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### Community Tax
|
|
40
|
+
|
|
41
|
+
The fraction of each block reward that is diverted to the community pool before distributing the remainder to validators and delegators.
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
community_tax = 0.02 → 2% of all block rewards go to the community pool
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
### Outstanding Rewards
|
|
50
|
+
|
|
51
|
+
Rewards that have been earned but **not yet withdrawn**. These accumulate on-chain until the validator or delegator explicitly claims them.
|
|
7
52
|
|
|
8
53
|
---
|
|
9
54
|
|
|
10
|
-
##
|
|
55
|
+
## Setup
|
|
11
56
|
|
|
12
57
|
```ts
|
|
13
|
-
import {
|
|
58
|
+
import {
|
|
59
|
+
ChainDistributionApi,
|
|
60
|
+
getNetworkEndpoints,
|
|
61
|
+
Network,
|
|
62
|
+
} from '@zuhaibnoor/zigchain-sdk'
|
|
63
|
+
|
|
64
|
+
const endpoints = getNetworkEndpoints(Network.Testnet)
|
|
65
|
+
const distributionApi = new ChainDistributionApi(endpoints)
|
|
66
|
+
|
|
67
|
+
const delegator = 'zig1q8uh4ytf632jqykrd4m0weuzq9uv4r4jzra9h6'
|
|
68
|
+
const validator = 'zigvaloper1pwwymlyeyfcz3pjvcegvz8tj3yf0pr3wqqhrwk'
|
|
14
69
|
```
|
|
15
70
|
|
|
16
71
|
---
|
|
17
72
|
|
|
18
|
-
|
|
73
|
+
# 1️⃣ fetchParams
|
|
74
|
+
|
|
75
|
+
## Method
|
|
19
76
|
|
|
20
77
|
```ts
|
|
21
|
-
|
|
78
|
+
async fetchParams()
|
|
22
79
|
```
|
|
23
80
|
|
|
24
|
-
|
|
81
|
+
## CLI Equivalent
|
|
25
82
|
|
|
26
|
-
|
|
83
|
+
```bash
|
|
84
|
+
zigchaind query distribution params
|
|
85
|
+
```
|
|
27
86
|
|
|
28
|
-
##
|
|
87
|
+
## Description
|
|
29
88
|
|
|
30
|
-
|
|
89
|
+
Fetches the **Distribution module parameters** configured at chain level.
|
|
31
90
|
|
|
32
|
-
|
|
91
|
+
These are governance-controlled settings that define how block rewards are split across the community pool, validators, and delegators. The most important parameter is `community_tax` — the fraction of every block reward redirected to the community pool before validator and delegator distribution.
|
|
33
92
|
|
|
34
|
-
|
|
35
|
-
Returns the commission accumulated by a specific validator from delegators’ rewards.
|
|
93
|
+
## Parameters
|
|
36
94
|
|
|
37
|
-
|
|
38
|
-
|
|
95
|
+
None.
|
|
96
|
+
|
|
97
|
+
## Usage Example
|
|
39
98
|
|
|
40
99
|
```ts
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
100
|
+
const params = await distributionApi.fetchParams()
|
|
101
|
+
console.dir(params, { depth: null })
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Example Response
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"params": {
|
|
109
|
+
"community_tax": "0.020000000000000000",
|
|
110
|
+
"base_proposer_reward": "0.000000000000000000",
|
|
111
|
+
"bonus_proposer_reward": "0.000000000000000000",
|
|
112
|
+
"withdraw_addr_enabled": true
|
|
113
|
+
}
|
|
114
|
+
}
|
|
44
115
|
```
|
|
45
116
|
|
|
117
|
+
## Response Field Explanation
|
|
118
|
+
|
|
119
|
+
### `params`
|
|
120
|
+
|
|
121
|
+
| Field | Description |
|
|
122
|
+
| ---------------------- | --------------------------------------------------------------------------------------- |
|
|
123
|
+
| community_tax | Fraction of each block reward sent to the community pool (`0.02` = 2%) |
|
|
124
|
+
| base_proposer_reward | Base bonus reward for the block proposer. Set to `0` on ZigChain |
|
|
125
|
+
| bonus_proposer_reward | Additional bonus for proposers based on included votes. Set to `0` on ZigChain |
|
|
126
|
+
| withdraw_addr_enabled | Whether delegators can set a custom reward withdrawal address (`true` = enabled) |
|
|
127
|
+
|
|
128
|
+
> On ZigChain, both proposer reward bonuses are set to `0`, meaning all validators earn equal reward rates regardless of whether they proposed the block. The 2% community tax applies to every block.
|
|
129
|
+
|
|
130
|
+
## When to Use
|
|
131
|
+
|
|
132
|
+
* Understanding how block rewards are split at the protocol level
|
|
133
|
+
* Verifying whether custom withdraw addresses are enabled
|
|
134
|
+
* Governance monitoring for parameter change proposals
|
|
135
|
+
|
|
46
136
|
---
|
|
47
137
|
|
|
48
|
-
|
|
138
|
+
# 2️⃣ fetchCommunityPool
|
|
49
139
|
|
|
50
|
-
|
|
51
|
-
Fetches the total balance of the **community pool**, which is used for governance-approved spending.
|
|
140
|
+
## Method
|
|
52
141
|
|
|
53
|
-
|
|
54
|
-
|
|
142
|
+
```ts
|
|
143
|
+
async fetchCommunityPool()
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## CLI Equivalent
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
zigchaind query distribution community-pool
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Description
|
|
153
|
+
|
|
154
|
+
Fetches the **current balance of the community pool**.
|
|
155
|
+
|
|
156
|
+
The community pool accumulates 2% of every block reward continuously. The balance shown includes fractional amounts tracked with high precision — these accumulate as decimal remainders from reward calculations.
|
|
157
|
+
|
|
158
|
+
## Parameters
|
|
159
|
+
|
|
160
|
+
None.
|
|
161
|
+
|
|
162
|
+
## Usage Example
|
|
55
163
|
|
|
56
164
|
```ts
|
|
57
|
-
const pool = await
|
|
165
|
+
const pool = await distributionApi.fetchCommunityPool()
|
|
166
|
+
console.dir(pool, { depth: null })
|
|
58
167
|
```
|
|
59
168
|
|
|
60
|
-
|
|
169
|
+
## Example Response
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
{
|
|
173
|
+
"pool": [
|
|
174
|
+
{
|
|
175
|
+
"denom": "uzig",
|
|
176
|
+
"amount": "243098073712.963766803812287124"
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Response Field Explanation
|
|
183
|
+
|
|
184
|
+
### `pool`
|
|
185
|
+
|
|
186
|
+
Array of coin balances in the community pool. Currently only `uzig` accumulates here on ZigChain testnet.
|
|
187
|
+
|
|
188
|
+
| Field | Description |
|
|
189
|
+
| ------ | --------------------------------------------------------------------------------- |
|
|
190
|
+
| denom | Token denomination in the pool |
|
|
191
|
+
| amount | High-precision decimal balance — includes fractional `uzig` from reward rounding |
|
|
61
192
|
|
|
62
|
-
|
|
193
|
+
## When to Use
|
|
63
194
|
|
|
64
|
-
|
|
65
|
-
|
|
195
|
+
* Governance dashboards displaying available community funds
|
|
196
|
+
* Tracking community pool growth over time
|
|
197
|
+
* Calculating how much is available for governance spending proposals
|
|
66
198
|
|
|
67
|
-
|
|
68
|
-
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
# 3️⃣ fetchDelegatorValidators
|
|
202
|
+
|
|
203
|
+
## Method
|
|
69
204
|
|
|
70
205
|
```ts
|
|
71
|
-
|
|
72
|
-
|
|
206
|
+
async fetchDelegatorValidators(delegator: string)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## CLI Equivalent
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
zigchaind query distribution delegator-validators <delegator>
|
|
73
213
|
```
|
|
74
214
|
|
|
215
|
+
## Description
|
|
216
|
+
|
|
217
|
+
Fetches the **list of validators a delegator is currently earning rewards from**.
|
|
218
|
+
|
|
219
|
+
This returns only validators with active delegations from the given address — validators where the delegator has staked tokens and is accumulating rewards. It does not include validators with zero delegation.
|
|
220
|
+
|
|
75
221
|
---
|
|
76
222
|
|
|
77
|
-
|
|
223
|
+
## Parameters
|
|
224
|
+
|
|
225
|
+
| Name | Type | Description |
|
|
226
|
+
| --------- | ------ | ---------------------------------------------- |
|
|
227
|
+
| delegator | string | Bech32 address of the delegator to query |
|
|
78
228
|
|
|
79
|
-
|
|
80
|
-
Fetches the withdraw address where a delegator’s rewards are sent.
|
|
229
|
+
---
|
|
81
230
|
|
|
82
|
-
|
|
83
|
-
Useful for checking whether a delegator has set a **custom reward withdrawal address**.
|
|
231
|
+
## Usage Example
|
|
84
232
|
|
|
85
233
|
```ts
|
|
86
|
-
const
|
|
87
|
-
|
|
234
|
+
const delegatorValidators = await distributionApi.fetchDelegatorValidators(delegator)
|
|
235
|
+
console.dir(delegatorValidators, { depth: null })
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Example Response
|
|
239
|
+
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"validators": [
|
|
243
|
+
"zigvaloper1q8uh4ytf632jqykrd4m0weuzq9uv4r4jhy3rkr"
|
|
244
|
+
]
|
|
245
|
+
}
|
|
88
246
|
```
|
|
89
247
|
|
|
248
|
+
## Response Field Explanation
|
|
249
|
+
|
|
250
|
+
### `validators`
|
|
251
|
+
|
|
252
|
+
Array of validator operator addresses (`zigvaloper...`) from which this delegator is earning rewards.
|
|
253
|
+
|
|
254
|
+
| Field | Description |
|
|
255
|
+
| ---------- | ----------------------------------------------------------------------- |
|
|
256
|
+
| validators | List of validator operator addresses with active delegations |
|
|
257
|
+
|
|
258
|
+
> In the example, this delegator has staked with exactly one validator. A delegator who has spread stake across multiple validators will see multiple entries here.
|
|
259
|
+
|
|
260
|
+
## When to Use
|
|
261
|
+
|
|
262
|
+
* Displaying a delegator's active staking positions
|
|
263
|
+
* Wallet dashboards showing which validators a user is staked with
|
|
264
|
+
* Building staking portfolio views
|
|
265
|
+
|
|
90
266
|
---
|
|
91
267
|
|
|
92
|
-
|
|
268
|
+
# 4️⃣ fetchDelegatorWithdrawAddress
|
|
269
|
+
|
|
270
|
+
## Method
|
|
271
|
+
|
|
272
|
+
```ts
|
|
273
|
+
async fetchDelegatorWithdrawAddress(delegator: string)
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## CLI Equivalent
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
zigchaind query distribution delegator-withdraw-address <delegator>
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Description
|
|
283
|
+
|
|
284
|
+
Fetches the **reward withdrawal address** configured for a delegator.
|
|
93
285
|
|
|
94
|
-
|
|
95
|
-
|
|
286
|
+
By default, this matches the delegator's own address. If the delegator has set a custom withdraw address, rewards will be sent there instead when claimed. This is useful for directing rewards to a separate cold wallet or treasury address.
|
|
287
|
+
|
|
288
|
+
---
|
|
96
289
|
|
|
97
|
-
|
|
98
|
-
|
|
290
|
+
## Parameters
|
|
291
|
+
|
|
292
|
+
| Name | Type | Description |
|
|
293
|
+
| --------- | ------ | ------------------------------------------------ |
|
|
294
|
+
| delegator | string | Bech32 address of the delegator to query |
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Usage Example
|
|
99
299
|
|
|
100
300
|
```ts
|
|
101
|
-
const
|
|
301
|
+
const withdrawAddr = await distributionApi.fetchDelegatorWithdrawAddress(delegator)
|
|
302
|
+
console.dir(withdrawAddr, { depth: null })
|
|
102
303
|
```
|
|
103
304
|
|
|
305
|
+
## Example Response
|
|
306
|
+
|
|
307
|
+
```json
|
|
308
|
+
{
|
|
309
|
+
"withdraw_address": "zig1q8uh4ytf632jqykrd4m0weuzq9uv4r4jzra9h6"
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Response Field Explanation
|
|
314
|
+
|
|
315
|
+
| Field | Description |
|
|
316
|
+
| ---------------- | ----------------------------------------------------------------------------------- |
|
|
317
|
+
| withdraw_address | Address where rewards will be sent when the delegator withdraws. Defaults to the delegator's own address. |
|
|
318
|
+
|
|
319
|
+
> When `withdraw_address` matches the delegator's own address (as in the example), no custom withdraw address has been set — this is the default state.
|
|
320
|
+
|
|
321
|
+
## When to Use
|
|
322
|
+
|
|
323
|
+
* Verifying where a delegator's rewards will be sent before withdrawal
|
|
324
|
+
* Wallet UIs displaying reward destination
|
|
325
|
+
* Confirming a custom withdraw address was set correctly
|
|
326
|
+
|
|
104
327
|
---
|
|
105
328
|
|
|
106
|
-
|
|
329
|
+
# 5️⃣ fetchValidatorCommission
|
|
107
330
|
|
|
108
|
-
|
|
109
|
-
Fetches **all staking rewards** earned by a delegator across **all validators**.
|
|
331
|
+
## Method
|
|
110
332
|
|
|
111
|
-
|
|
112
|
-
|
|
333
|
+
```ts
|
|
334
|
+
async fetchValidatorCommission(validator: string)
|
|
335
|
+
```
|
|
113
336
|
|
|
114
|
-
|
|
337
|
+
## CLI Equivalent
|
|
115
338
|
|
|
339
|
+
```bash
|
|
340
|
+
zigchaind query distribution commission <validator>
|
|
116
341
|
```
|
|
117
|
-
|
|
342
|
+
|
|
343
|
+
## Description
|
|
344
|
+
|
|
345
|
+
Fetches the **accumulated commission** that a validator has earned but not yet withdrawn.
|
|
346
|
+
|
|
347
|
+
Commission is the validator's share of delegator rewards, taken at the validator's configured commission rate each block. It accumulates continuously until the validator explicitly withdraws it.
|
|
348
|
+
|
|
349
|
+
## Parameters
|
|
350
|
+
|
|
351
|
+
| Name | Type | Description |
|
|
352
|
+
| --------- | ------ | ----------------------------------------------------- |
|
|
353
|
+
| validator | string | Validator operator address (`zigvaloper...`) to query |
|
|
354
|
+
|
|
355
|
+
## Usage Example
|
|
356
|
+
|
|
357
|
+
```ts
|
|
358
|
+
const commission = await distributionApi.fetchValidatorCommission(validator)
|
|
359
|
+
console.dir(commission, { depth: null })
|
|
118
360
|
```
|
|
119
361
|
|
|
362
|
+
## Example Response
|
|
363
|
+
|
|
364
|
+
```json
|
|
365
|
+
{
|
|
366
|
+
"commission": {
|
|
367
|
+
"commission": [
|
|
368
|
+
{
|
|
369
|
+
"denom": "uzig",
|
|
370
|
+
"amount": "221571475888.997127352507253303"
|
|
371
|
+
}
|
|
372
|
+
]
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
## Response Field Explanation
|
|
378
|
+
|
|
379
|
+
### `commission.commission`
|
|
380
|
+
|
|
381
|
+
Array of outstanding commission amounts per denom.
|
|
382
|
+
|
|
383
|
+
| Field | Description |
|
|
384
|
+
| ------ | ---------------------------------------------------------------------------------- |
|
|
385
|
+
| denom | Token denomination of the commission |
|
|
386
|
+
| amount | High-precision accumulated commission amount not yet withdrawn by the validator |
|
|
387
|
+
|
|
388
|
+
> `221571475888 uzig` ≈ 221,571 ZIG in outstanding commission for this validator — reflecting the high activity of a top validator on ZigChain testnet.
|
|
389
|
+
|
|
390
|
+
## When to Use
|
|
391
|
+
|
|
392
|
+
* Validator dashboards showing pending commission to withdraw
|
|
393
|
+
* Comparing commission accumulation across validators
|
|
394
|
+
|
|
120
395
|
---
|
|
121
396
|
|
|
122
|
-
|
|
397
|
+
# 6️⃣ fetchDelegatorRewards
|
|
123
398
|
|
|
124
|
-
|
|
125
|
-
Returns rewards earned by a delegator **from a specific validator only**.
|
|
399
|
+
## Method
|
|
126
400
|
|
|
127
|
-
|
|
128
|
-
|
|
401
|
+
```ts
|
|
402
|
+
async fetchDelegatorRewards(delegator: string)
|
|
403
|
+
```
|
|
129
404
|
|
|
130
|
-
|
|
405
|
+
## CLI Equivalent
|
|
131
406
|
|
|
407
|
+
```bash
|
|
408
|
+
zigchaind query distribution rewards <delegator-address>
|
|
132
409
|
```
|
|
133
|
-
|
|
410
|
+
|
|
411
|
+
## Description
|
|
412
|
+
|
|
413
|
+
Fetches **all pending staking rewards** accumulated by a delegator across every validator they are staked with.
|
|
414
|
+
|
|
415
|
+
Returns a per-validator breakdown of rewards as well as the combined total across all validators. Rewards accumulate each block and remain here until the delegator explicitly withdraws them.
|
|
416
|
+
|
|
417
|
+
## Parameters
|
|
418
|
+
|
|
419
|
+
| Name | Type | Description |
|
|
420
|
+
| --------- | ------ | ---------------------------------------------- |
|
|
421
|
+
| delegator | string | Bech32 address of the delegator to query |
|
|
422
|
+
|
|
423
|
+
## Usage Example
|
|
424
|
+
|
|
425
|
+
```ts
|
|
426
|
+
const rewards = await distributionApi.fetchDelegatorRewards(delegator)
|
|
427
|
+
console.dir(rewards, { depth: null })
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
## Example Response
|
|
431
|
+
|
|
432
|
+
```json
|
|
433
|
+
{
|
|
434
|
+
"rewards": [
|
|
435
|
+
{
|
|
436
|
+
"validator_address": "zigvaloper1q8uh4ytf632jqykrd4m0weuzq9uv4r4jhy3rkr",
|
|
437
|
+
"reward": []
|
|
438
|
+
}
|
|
439
|
+
],
|
|
440
|
+
"total": []
|
|
441
|
+
}
|
|
134
442
|
```
|
|
135
443
|
|
|
444
|
+
## Response Field Explanation
|
|
445
|
+
|
|
446
|
+
### `rewards`
|
|
447
|
+
|
|
448
|
+
Array of per-validator reward entries for this delegator.
|
|
449
|
+
|
|
450
|
+
| Field | Description |
|
|
451
|
+
| ----------------- | ------------------------------------------------------------------------ |
|
|
452
|
+
| validator_address | Validator operator address this reward entry is associated with |
|
|
453
|
+
| reward | Array of pending reward coins from this validator. Empty if none pending |
|
|
454
|
+
|
|
455
|
+
### `total`
|
|
456
|
+
|
|
457
|
+
Aggregated rewards across all validators combined.
|
|
458
|
+
|
|
459
|
+
| Field | Description |
|
|
460
|
+
| ----- | --------------------------------------------------------------------- |
|
|
461
|
+
| total | Array of total pending reward coins. Empty if no rewards are pending |
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
## When to Use
|
|
465
|
+
|
|
466
|
+
* Wallet dashboards displaying a user's total pending rewards
|
|
467
|
+
* Showing per-validator reward breakdown before withdrawal
|
|
468
|
+
* Calculating total claimable rewards across all staking positions
|
|
469
|
+
|
|
136
470
|
---
|
|
137
471
|
|
|
138
|
-
|
|
472
|
+
# 7️⃣ fetchDelegatorRewardsByValidator
|
|
139
473
|
|
|
140
|
-
|
|
141
|
-
Fetches **slashing events** applied to a validator, including the slashing fraction and period.
|
|
474
|
+
## Method
|
|
142
475
|
|
|
143
|
-
|
|
144
|
-
|
|
476
|
+
```ts
|
|
477
|
+
async fetchDelegatorRewardsByValidator(delegator: string, validator: string)
|
|
478
|
+
```
|
|
145
479
|
|
|
146
|
-
|
|
480
|
+
## CLI Equivalent
|
|
147
481
|
|
|
482
|
+
```bash
|
|
483
|
+
zigchaind query distribution rewards-by-validator <delegator> <validator>
|
|
148
484
|
```
|
|
149
|
-
|
|
485
|
+
|
|
486
|
+
## Description
|
|
487
|
+
|
|
488
|
+
Fetches the **pending rewards earned by a delegator from a single specific validator**.
|
|
489
|
+
|
|
490
|
+
This is the targeted alternative to `fetchDelegatorRewards` — use this when you only need the reward from one particular validator rather than the full cross-validator breakdown.
|
|
491
|
+
|
|
492
|
+
## Parameters
|
|
493
|
+
|
|
494
|
+
| Name | Type | Description |
|
|
495
|
+
| --------- | ------ | ------------------------------------------------------- |
|
|
496
|
+
| delegator | string | Bech32 address of the delegator |
|
|
497
|
+
| validator | string | Validator operator address (`zigvaloper...`) to query |
|
|
498
|
+
|
|
499
|
+
## Usage Example
|
|
500
|
+
|
|
501
|
+
```ts
|
|
502
|
+
const rewardsByVal = await distributionApi.fetchDelegatorRewardsByValidator(
|
|
503
|
+
delegator,
|
|
504
|
+
'zigvaloper1q8uh4ytf632jqykrd4m0weuzq9uv4r4jhy3rkr'
|
|
505
|
+
)
|
|
506
|
+
console.dir(rewardsByVal, { depth: null })
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
## Example Response
|
|
510
|
+
|
|
511
|
+
```json
|
|
512
|
+
{
|
|
513
|
+
"rewards": []
|
|
514
|
+
}
|
|
150
515
|
```
|
|
151
516
|
|
|
517
|
+
## Response Field Explanation
|
|
518
|
+
|
|
519
|
+
### `rewards`
|
|
520
|
+
|
|
521
|
+
Array of pending reward coins from this specific validator.
|
|
522
|
+
|
|
523
|
+
| Field | Description |
|
|
524
|
+
| ------- | ----------------------------------------------------------------------- |
|
|
525
|
+
| rewards | Array of coin amounts pending from this validator. Empty if none pending |
|
|
526
|
+
|
|
527
|
+
### `fetchDelegatorRewards` vs `fetchDelegatorRewardsByValidator`
|
|
528
|
+
|
|
529
|
+
| Feature | fetchDelegatorRewards | fetchDelegatorRewardsByValidator |
|
|
530
|
+
| -------------------------- | --------------------------- | --------------------------------- |
|
|
531
|
+
| Scope | All validators | Single validator only |
|
|
532
|
+
| Includes total | ✅ Yes | ❌ No |
|
|
533
|
+
| Use case | Full portfolio rewards view | Per-validator reward inspection |
|
|
534
|
+
|
|
535
|
+
## When to Use
|
|
536
|
+
|
|
537
|
+
* Per-validator reward analytics
|
|
538
|
+
* Validator-specific staking dashboards
|
|
539
|
+
* Comparing reward rates across different validators a delegator uses
|
|
540
|
+
|
|
152
541
|
---
|
|
153
542
|
|
|
154
|
-
|
|
543
|
+
# 8️⃣ fetchValidatorSlashes
|
|
155
544
|
|
|
156
|
-
|
|
157
|
-
Returns a validator’s **distribution overview**, including self-bond rewards and commission earned.
|
|
545
|
+
## Method
|
|
158
546
|
|
|
159
|
-
|
|
160
|
-
|
|
547
|
+
```ts
|
|
548
|
+
async fetchValidatorSlashes(validator: string)
|
|
549
|
+
```
|
|
161
550
|
|
|
162
|
-
|
|
551
|
+
## CLI Equivalent
|
|
163
552
|
|
|
553
|
+
```bash
|
|
554
|
+
zigchaind query distribution slashes <validator-address>
|
|
164
555
|
```
|
|
165
|
-
|
|
556
|
+
|
|
557
|
+
## Description
|
|
558
|
+
|
|
559
|
+
Fetches the **slashing history** of a specific validator.
|
|
560
|
+
|
|
561
|
+
A slash is a penalty applied to a validator (and proportionally to their delegators) for misbehaviour — such as double signing a block or extended downtime. Each slash event records the period it occurred in and the fraction of stake that was penalized.
|
|
562
|
+
|
|
563
|
+
An empty `slashes` array means the validator has **no recorded slashing events** — a good sign of validator reliability.
|
|
564
|
+
|
|
565
|
+
## Parameters
|
|
566
|
+
|
|
567
|
+
| Name | Type | Description |
|
|
568
|
+
| --------- | ------ | ----------------------------------------------------- |
|
|
569
|
+
| validator | string | Validator operator address (`zigvaloper...`) to query |
|
|
570
|
+
|
|
571
|
+
## Usage Example
|
|
572
|
+
|
|
573
|
+
```ts
|
|
574
|
+
const slashes = await distributionApi.fetchValidatorSlashes(validator)
|
|
575
|
+
console.dir(slashes, { depth: null })
|
|
166
576
|
```
|
|
167
577
|
|
|
578
|
+
## Example Response
|
|
579
|
+
|
|
580
|
+
```json
|
|
581
|
+
{
|
|
582
|
+
"slashes": [],
|
|
583
|
+
"pagination": {
|
|
584
|
+
"next_key": null,
|
|
585
|
+
"total": "0"
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
## Response Field Explanation
|
|
591
|
+
|
|
592
|
+
### `slashes`
|
|
593
|
+
|
|
594
|
+
Array of slashing events applied to this validator. Empty means no slashes on record.
|
|
595
|
+
|
|
596
|
+
If slash events are present, each entry would contain:
|
|
597
|
+
|
|
598
|
+
| Field | Description |
|
|
599
|
+
| ---------------- | -------------------------------------------------------------------- |
|
|
600
|
+
| validator_period | The distribution period during which the slash occurred |
|
|
601
|
+
| fraction | The fraction of stake that was slashed (e.g. `0.05` = 5% penalty) |
|
|
602
|
+
|
|
603
|
+
### `pagination`
|
|
604
|
+
|
|
605
|
+
| Field | Description |
|
|
606
|
+
| -------- | ---------------------------------------------------- |
|
|
607
|
+
| next_key | Cursor for next page. `null` if all results returned |
|
|
608
|
+
| total | Total number of slash events recorded |
|
|
609
|
+
|
|
610
|
+
> `total: '0'` for this validator confirms a clean slashing history — no misbehaviour has been recorded.
|
|
611
|
+
|
|
612
|
+
## When to Use
|
|
613
|
+
|
|
614
|
+
* Assessing validator reliability before delegating
|
|
615
|
+
* Building validator comparison and reputation dashboards
|
|
616
|
+
* Monitoring validators for new slash events
|
|
617
|
+
|
|
168
618
|
---
|
|
169
619
|
|
|
170
|
-
|
|
620
|
+
# 9️⃣ fetchValidatorDistributionInfo
|
|
621
|
+
|
|
622
|
+
## Method
|
|
623
|
+
|
|
624
|
+
```ts
|
|
625
|
+
async fetchValidatorDistributionInfo(validator: string)
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
## CLI Equivalent
|
|
629
|
+
|
|
630
|
+
```bash
|
|
631
|
+
zigchaind query distribution validator-distribution-info <validator-address>
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
## Description
|
|
635
|
+
|
|
636
|
+
Fetches a **complete distribution overview for a validator**, including their self-bond rewards and accumulated commission — all in a single query.
|
|
637
|
+
|
|
638
|
+
This is the most comprehensive single-call view of a validator's earnings from the distribution module. It shows both the rewards earned on the validator's own staked tokens and the commission earned from delegator rewards.
|
|
639
|
+
|
|
640
|
+
## Parameters
|
|
641
|
+
|
|
642
|
+
| Name | Type | Description |
|
|
643
|
+
| --------- | ------ | ----------------------------------------------------- |
|
|
644
|
+
| validator | string | Validator operator address (`zigvaloper...`) to query |
|
|
645
|
+
|
|
646
|
+
## Usage Example
|
|
647
|
+
|
|
648
|
+
```ts
|
|
649
|
+
const distInfo = await distributionApi.fetchValidatorDistributionInfo(validator)
|
|
650
|
+
console.dir(distInfo, { depth: null })
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
## Example Response
|
|
654
|
+
|
|
655
|
+
```json
|
|
656
|
+
{
|
|
657
|
+
"operator_address": "zig1pwwymlyeyfcz3pjvcegvz8tj3yf0pr3w48m900",
|
|
658
|
+
"self_bond_rewards": [
|
|
659
|
+
{
|
|
660
|
+
"denom": "uzig",
|
|
661
|
+
"amount": "744261754912.141600000000000000"
|
|
662
|
+
}
|
|
663
|
+
],
|
|
664
|
+
"commission": [
|
|
665
|
+
{
|
|
666
|
+
"denom": "uzig",
|
|
667
|
+
"amount": "221589430188.073196173617296226"
|
|
668
|
+
}
|
|
669
|
+
]
|
|
670
|
+
}
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
## Response Field Explanation
|
|
674
|
+
|
|
675
|
+
| Field | Description |
|
|
676
|
+
| ----------------- | ----------------------------------------------------------------------------------- |
|
|
677
|
+
| operator_address | The validator's account address (`zig...`) — where rewards are sent on withdrawal |
|
|
678
|
+
| self_bond_rewards | Pending rewards earned on the validator's own self-delegated stake |
|
|
679
|
+
| commission | Pending commission accumulated from delegator rewards, not yet withdrawn |
|
|
680
|
+
|
|
681
|
+
### `self_bond_rewards` and `commission`
|
|
682
|
+
|
|
683
|
+
Both fields are arrays of coin amounts with high-precision decimal values:
|
|
684
|
+
|
|
685
|
+
| Field | Description |
|
|
686
|
+
| ------ | ------------------------------------------------------------- |
|
|
687
|
+
| denom | Token denomination |
|
|
688
|
+
| amount | High-precision accumulated amount including decimal remainder |
|
|
689
|
+
|
|
690
|
+
> For this validator: ~744,261 ZIG in self-bond rewards and ~221,589 ZIG in commission are outstanding — both reflecting a high-activity top validator on ZigChain testnet.
|
|
691
|
+
|
|
692
|
+
### Total Validator Earnings Breakdown
|
|
693
|
+
|
|
694
|
+
| Source | Field | Description |
|
|
695
|
+
| ----------------- | ------------------ | ---------------------------------------- |
|
|
696
|
+
| Own stake rewards | self_bond_rewards | Earned as a delegator on own validator |
|
|
697
|
+
| Commission | commission | Earned as a percentage of delegator rewards |
|
|
171
698
|
|
|
172
|
-
|
|
173
|
-
Fetches **unwithdrawn (outstanding) rewards** for a validator and all of its delegations.
|
|
699
|
+
## When to Use
|
|
174
700
|
|
|
175
|
-
|
|
176
|
-
|
|
701
|
+
* Validator dashboards showing total pending earnings in one call
|
|
702
|
+
* Comparing validator self-bond rewards vs commission income
|
|
703
|
+
* Calculating total validator revenue for analytics
|
|
704
|
+
---
|
|
705
|
+
|
|
706
|
+
# 🔟 fetchValidatorOutstandingRewards
|
|
177
707
|
|
|
178
|
-
|
|
708
|
+
## Method
|
|
179
709
|
|
|
710
|
+
```ts
|
|
711
|
+
async fetchValidatorOutstandingRewards(validator: string)
|
|
180
712
|
```
|
|
713
|
+
|
|
714
|
+
## CLI Equivalent
|
|
715
|
+
|
|
716
|
+
```bash
|
|
181
717
|
zigchaind query distribution validator-outstanding-rewards <validator-address>
|
|
182
718
|
```
|
|
183
719
|
|
|
184
720
|
---
|
|
185
721
|
|
|
186
|
-
##
|
|
722
|
+
## Description
|
|
723
|
+
|
|
724
|
+
Fetches the **total outstanding rewards** for a validator — the sum of all unwithdrawn rewards across all delegations to that validator, plus the validator's own pending commission and self-bond rewards.
|
|
725
|
+
|
|
726
|
+
This represents the complete pool of rewards sitting in the distribution module that are attributable to this validator, across every participant who has not yet withdrawn.
|
|
187
727
|
|
|
188
|
-
| Function | What it tells you |
|
|
189
|
-
| ------------------------------- | ------------------------------------------ |
|
|
190
|
-
| `fetchValidatorCommission` | How much commission a validator has earned |
|
|
191
|
-
| `fetchCommunityPool` | Total funds in the community pool |
|
|
192
|
-
| `fetchDelegatorValidators` | Validators paying rewards to a delegator |
|
|
193
|
-
| `fetchDelegatorWithdrawAddress` | Where delegator rewards are withdrawn |
|
|
194
|
-
| `fetchParams` | Network-wide reward distribution rules |
|
|
195
|
-
| `fetchDelegatorRewards` | Get all staking rewards for a delegator across all validators |
|
|
196
|
-
| `fetchDelegatorRewardsByValidator` | Get delegator rewards from a specific validator |
|
|
197
|
-
| `fetchValidatorSlashes` | Query slashing events applied to a validator |
|
|
198
|
-
| `fetchValidatorDistributionInfo` | Fetch validator commission and self-bond rewards |
|
|
199
|
-
| `fetchValidatorOutstandingRewards` | Get unwithdrawn rewards for a validator |
|
|
200
728
|
---
|
|
201
729
|
|
|
730
|
+
## Parameters
|
|
731
|
+
|
|
732
|
+
| Name | Type | Description |
|
|
733
|
+
| --------- | ------ | ----------------------------------------------------- |
|
|
734
|
+
| validator | string | Validator operator address (`zigvaloper...`) to query |
|
|
735
|
+
|
|
736
|
+
---
|
|
737
|
+
|
|
738
|
+
## Usage Example
|
|
739
|
+
|
|
740
|
+
```ts
|
|
741
|
+
const outstanding = await distributionApi.fetchValidatorOutstandingRewards(validator)
|
|
742
|
+
console.dir(outstanding, { depth: null })
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
## Example Response
|
|
746
|
+
|
|
747
|
+
```json
|
|
748
|
+
{
|
|
749
|
+
"rewards": {
|
|
750
|
+
"rewards": [
|
|
751
|
+
{
|
|
752
|
+
"denom": "uzig",
|
|
753
|
+
"amount": "985083471414.779638309606269193"
|
|
754
|
+
}
|
|
755
|
+
]
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
## Response Field Explanation
|
|
761
|
+
|
|
762
|
+
### `rewards.rewards`
|
|
763
|
+
|
|
764
|
+
Array of total outstanding reward amounts across all delegations to this validator.
|
|
765
|
+
|
|
766
|
+
| Field | Description |
|
|
767
|
+
| ------ | --------------------------------------------------------------------------------- |
|
|
768
|
+
| denom | Token denomination |
|
|
769
|
+
| amount | Total unwithdrawn rewards attributable to this validator, with high-precision decimals |
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
---
|