[Feature] API endpoint for staking rewards
🚀 Feature Request
Provide two new API endpoints: 1. An endpoint to query the staking rewards generated by a validator per epoch. 2. An endpoint to query the staking rewards paid to a specific wallet per epoch.
🎯 Motivation
Access to staking reward data is essential for accounting, auditing, and transparency. Many blockchain networks already expose reward information through APIs, and adding this functionality would align with industry standards while making it easier for users and integrators to track validator and wallet-level rewards programmatically.
Implementation
Add a read-only rewards service that indexes on-chain reward events and exposes two REST endpoints: 1. Validator rewards per epoch 2. Wallet-paid rewards per epoch
The service should tolerate reorgs, support backfill, and return deterministic, audit-friendly results.
If you build and sync a node with --features history you can query historic values of credits.aleo mappings bonded, delegated, metadata, unbonding and withdraw via /history/{mapping}.
Staking rewards are added to the bonded and delegated after every block. If you subtract any amounts which you bonded/delegated yourself, you then know your staking amounts.
Does this give you what you need?
If you can run my explorer locally, it currently has staking reward tracking for every address, recorded per 100 blocks (due to disk usage constraints).
Currently it's not exposed to APIs, and the data is not per-epoch (100 was chosen arbitrarily), but you can modify the code to your needs.
Keep in mind that the code is under strong copyleft license if you decide to use it.
If you build and sync a node with
--features historyyou can query historic values of credits.aleo mappingsbonded,delegated,metadata,unbondingandwithdrawvia/history/{mapping}.Staking rewards are added to the
bondedanddelegatedafter every block. If you subtract any amounts which you bonded/delegated yourself, you then know your staking amounts.Does this give you what you need?
@HarukaMa This is helpful, thank you.