Querying rewards
Example query to summarise the earned rewards on a Cardano staking address.
When you stake your ADA holdings, you will receive a reward every five days at the end of each Cardano epoch.
Your Cardano accounts are associated with a staking address. We will be querying the blockchain for rewards received on that staking address.
SELECT sa.stake_address, r.epoch_no, r.amount,
sum(r.amount) OVER (ORDER BY r.epoch_no) AS cummulative
FROM `blockchain-analytics-392322.cardano_mainnet.rel_stake_hash` AS sa
JOIN `blockchain-analytics-392322.cardano_mainnet.reward` AS r
ON r.stake_addr_hash = sa.stake_addr_hash
WHERE sa.stake_address = 'stake1abcdefghijklmnopqrstuvwxyz0123456789'
AND r.epoch_no > 480 AND r.epoch_no < 500
ORDER BY r.epoch_no;
querying for rewards on a staking address in a limited range of epochs.
The output of the above query:
stake_address | epoch_no | amount | cummulative |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 481 | 54476238 | 54476238 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 482 | 37631854 | 92108092 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 483 | 49544915 | 141653007 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 484 | 42372153 | 184025160 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 485 | 44469691 | 228494851 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 486 | 39670503 | 268165354 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 487 | 34682468 | 302847822 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 488 | 54762878 | 357610700 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 489 | 46136764 | 403747464 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 490 | 53921323 | 457668787 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 491 | 45530627 | 503199414 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 492 | 62136642 | 565336056 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 493 | 56945124 | 622281180 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 494 | 65592343 | 687873523 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 495 | 43057861 | 730931384 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 496 | 42957958 | 773889342 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 497 | 46514213 | 820403555 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 498 | 44814113 | 865217668 |
stake1abcdefghijklmnopqrstuvwxyz0123456789 | 499 | 55978143 | 921195811 |
Running the above query processes almost 2 GB of BigQuery credits. Yet, it is run only seldom.