1

I have tried using api/packages/api-derive/src/staking/erasRewards.ts, but I do not understand what titrates the number of eras being shown. Also, whose rewards am I looking at? All rewards in that given era?

Here's my code snippet:

const data = await api.derive.staking.erasRewards(); 
console.log(data.map(n => n['era'].toHuman() + ": " + n['eraReward'].toHuman()));

out:

[
  '727: 2,551,955,748,462,398',
  '728: 2,563,279,047,583,848',
  '729: 2,563,370,718,401,581',
  '730: 2,566,416,999,724,756',
  '731: 2,579,735,528,770,578',
  '732: 2,580,391,954,273,350',
  '733: 2,574,770,240,650,025',
  '734: 2,574,423,145,452,759',
  '735: 2,572,961,896,036,511',
  '736: 2,572,752,562,942,962',
  '737: 2,575,640,277,891,519',
  '738: 2,575,174,055,033,005',
  '739: 2,572,164,587,614,876',
  '740: 2,574,636,183,355,342',
  '741: 2,575,348,329,001,013',
  '742: 2,556,461,500,268,646',
  '743: 2,556,729,480,475,956',
  '744: 2,557,482,295,343,475',
  '745: 2,533,870,094,301,476',
  '746: 2,527,530,013,839,401',
  '747: 2,527,804,229,223,442',
  '748: 2,528,033,816,896,959',
  '749: 2,533,785,921,746,221',
  '750: 2,534,274,185,050,776',
  '751: 2,538,036,804,329,962',
  '752: 2,537,897,849,156,071',
  '753: 2,537,564,847,212,898',
  '754: 2,538,531,966,424,070',
  '755: 2,539,108,793,068,694',
  '756: 2,540,608,123,105,699',
  '757: 2,540,897,813,019,624',
  '758: 2,540,220,548,628,705',
  '759: 2,540,499,187,276,898',
  '760: 2,535,471,076,137,138',
  '761: 2,537,161,861,178,588',
  '762: 2,537,712,672,567,210',
  '763: 2,538,354,552,093,822',
  '764: 2,539,370,254,053,080',
  '765: 2,539,498,967,691,432',
  '766: 2,537,985,738,070,300',
  '767: 2,539,672,793,438,627',
  '768: 2,547,647,218,090,372',
  '769: 2,548,407,690,287,302',
  '770: 2,549,213,979,480,129',
  '771: 2,541,633,869,358,439',
  '772: 2,547,817,357,135,217',
  '773: 2,547,432,369,360,853',
  '774: 2,547,718,144,532,895',
  '775: 2,549,267,291,525,198',
  '776: 2,550,814,915,082,432',
  '777: 2,551,440,540,362,707',
  '778: 2,553,256,619,503,668',
  '779: 2,552,954,215,201,388',
  '780: 2,553,460,158,045,053',
  '781: 2,556,438,206,416,740',
  '782: 2,558,118,980,257,812',
  '783: 2,559,147,608,644,081',
  '784: 2,560,633,251,102,886',
  '785: 2,562,597,178,237,471',
  '786: 2,562,751,449,521,687',
  '787: 2,566,234,007,347,650',
  '788: 2,565,712,211,377,681',
  '789: 2,566,815,672,241,032',
  '790: 2,567,044,191,299,448',
  '791: 2,567,605,353,041,866',
  '792: 2,568,789,496,998,416',
  '793: 2,567,509,775,385,522',
  '794: 2,569,839,818,841,921',
  '795: 2,569,981,058,027,446',
  '796: 2,566,746,092,399,327',
  '797: 2,566,853,946,849,154',
  '798: 2,567,661,511,732,652',
  '799: 2,567,730,503,536,287',
  '800: 2,572,088,096,172,078',
  '801: 2,570,797,107,149,885',
  '802: 2,572,428,261,633,356',
  '803: 2,576,551,669,974,451',
  '804: 2,577,565,186,348,720',
  '805: 2,578,034,696,990,158',
  '806: 2,578,387,595,911,190',
  '807: 2,578,369,699,479,845',
  '808: 2,578,868,063,338,523',
  '809: 2,579,517,724,773,635',
  '810: 2,574,743,424,098,730'
]

I also tried using api/packages/api-derive/src/staking/stakerRewards.ts, but I kept getting an empty array output.

Code:

const data = await api.derive.staking.stakerRewards('11uMPbeaEDJhUxzU4ZfWW9VQEsryP9XqFcNRfPdYda6aFWJ');
console.log(data)

Out:

[]

How do I fetch all the rewards paid to a specific account?

2

1 Answer 1

1

What you are looking at from your first query is the total payout of the whole era. It amounts to about 255k DOT.

The information of past payouts is stored in events. It is not held in storage permanently as that would only inflate the storage. This information is therefore not available in a standard Polkadot node.

You either need:

  • An archive node, since that stores all past events.
  • An indexing service that stores these events and makes them queryable for you.

In case you have that, the Staking::Rewarded event contains the receiver and the amount of each payout.
A Staking::PayoutStarted event before that indicates from which era and validator the rewards are.

1
  • Thank you! I was quite lost. Do you know of a list of archive nodes I can connect to?
    – Teo
    Aug 23, 2022 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.