snarkOS icon indicating copy to clipboard operation
snarkOS copied to clipboard

[Feature] API endpoint for staking rewards

Open cbolden-bd opened this issue 4 months ago • 3 comments

🚀 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.

cbolden-bd avatar Aug 21 '25 22:08 cbolden-bd

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?

vicsn avatar Aug 22 '25 11:08 vicsn

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.

HarukaMa avatar Aug 22 '25 13:08 HarukaMa

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?

@HarukaMa This is helpful, thank you.

cbolden-bd avatar Aug 26 '25 20:08 cbolden-bd