How to Use getInflationReward
Learn getInflationReward use cases, code examples, request parameters, response structure, and tips.
The getInflationReward
RPC method allows you to query the inflation rewards (commonly known as staking rewards) that were credited to one or more addresses for a specific epoch.
This is useful for verifying rewards received by stake accounts or any account that might have received inflation rewards.
Common Use Cases
- Verify Staking Rewards: Check if a stake account received the expected rewards for a past epoch.
- Track Reward History: Query rewards for multiple epochs to build a history for an address.
- Audit Validator Payouts: Validators can use this to verify reward distribution (though rewards are paid to stake accounts, not directly to validator identities).
Request Parameters
The method takes two main parameters:
addresses
(array of strings): A list of base-58 encoded public keys for the accounts you want to query. The maximum number of addresses allowed may vary depending on the RPC provider (e.g., Helius allows up to 1005 for paid plans).config
(object, optional): A configuration object with the following optional fields:commitment
(string, optional): Specifies the commitment level. Defaults tofinalized
if not provided.epoch
(integer, optional): The epoch number for which to fetch the rewards. If omitted, the RPC node will typically use the most recently completed epoch for which rewards have been distributed.minContextSlot
(integer, optional): The minimum slot that the request can be evaluated at. This ensures the query is made against a ledger state that has processed up to at least this slot.
Response Structure
The result
field of the JSON-RPC response will be an array corresponding to the input addresses
array. Each element in the result array will either be:
- An object containing the inflation reward details if the address received a reward for the specified epoch.
null
if the address did not receive an inflation reward for that epoch or if the account did not exist.
The reward object has the following fields:
epoch
(u64): The epoch for which this reward was credited.effectiveSlot
(u64): The slot in which the reward was applied and became effective.amount
(u64): The amount of the reward, in lamports.postBalance
(u64): The balance of the account, in lamports, after the reward was credited.commission
(u8 | undefined): For vote accounts, this is the commission percentage (0-100) taken by the validator at the time the reward was credited. It will beundefined
for non-vote accounts.
Examples
1. Get Inflation Reward for a Single Address (Previous Epoch)
This example fetches the inflation reward for a specific address for the most recently completed epoch.
2. Get Inflation Rewards for Multiple Addresses for a Specific Epoch
Developer Tips
- Epoch Specificity: Rewards are credited once per epoch. Ensure you are querying for the correct epoch number.
- Timing of Rewards: Inflation rewards are calculated at the end of an epoch and applied at the beginning of the next. The
effectiveSlot
indicates when this happens. - Null Results: A
null
result for an address means no reward was found for that address in the specified epoch. This could be because the account wasn’t eligible (e.g., not a sufficiently staked stake account), the reward was zero, or the account didn’t exist at that time. - Rate Limits: Be mindful of RPC provider rate limits, especially when querying for a large number of addresses.
This guide helps you use the getInflationReward
method to accurately retrieve and verify staking rewards on the Solana network.