getInflationReward
Returns the inflation reward credited to each supplied address for an epoch. Depending on the supplied address, this may be a staking reward or a voting reward.
Request
Send a JSON-RPC 2.0 POST request with method: "getInflationReward". The params array takes a list of base-58 encoded addresses and an optional configuration object.
curl · JSON-RPCjson
{ "jsonrpc": "2.0", "id": 1, "method": "getInflationReward", "params": [ [ "6dmNQ5jwLeLk5REvio1JcMshcbvkYMwy26sJ8pbkvStu", "BGsqMegLpV6n6Ve146sSX2dTjUMj3M92HnU8BbNRMhF2" ], { "epoch": 800, "commitment": "finalized" } ]}@solana/kit
kit.tsts
import { address, createSolanaRpc } from "@solana/kit"; const rpc_url = "https://rpc.openinfra.sh";const rpc = createSolanaRpc(rpc_url); let addresses = [ address("6dmNQ5jwLeLk5REvio1JcMshcbvkYMwy26sJ8pbkvStu"), address("BGsqMegLpV6n6Ve146sSX2dTjUMj3M92HnU8BbNRMhF2")]; let epoch = BigInt(2); let inflationReward = await rpc.getInflationReward(addresses, { epoch }).send(); console.log(inflationReward);@solana/web3.js
web3.tsts
import { Connection, PublicKey, clusterApiUrl } from "@solana/web3.js"; const connection = new Connection("https://rpc.openinfra.sh", "confirmed"); let addresses = [ new PublicKey("6dmNQ5jwLeLk5REvio1JcMshcbvkYMwy26sJ8pbkvStu"), new PublicKey("BGsqMegLpV6n6Ve146sSX2dTjUMj3M92HnU8BbNRMhF2")]; let epoch = 2; let inflationReward = await connection.getInflationReward(addresses, epoch); console.log(inflationReward);Rust
main.rsrs
use anyhow::Result;use solana_client::nonblocking::rpc_client::RpcClient;use solana_commitment_config::CommitmentConfig;use solana_sdk::pubkey; #[tokio::main]async fn main() -> Result<()> { let client = RpcClient::new_with_commitment( String::from("https://rpc.openinfra.sh"), CommitmentConfig::confirmed(), ); let addresses = [ pubkey!("6dmNQ5jwLeLk5REvio1JcMshcbvkYMwy26sJ8pbkvStu"), pubkey!("BGsqMegLpV6n6Ve146sSX2dTjUMj3M92HnU8BbNRMhF2"), ]; let epoch = 2; let inflation_reward = client.get_inflation_reward(&addresses, Some(epoch)).await?; println!("{:#?}", inflation_reward); Ok(())}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| addresses | array | Yes | An array of addresses to query, as base-58 encoded strings. |
| config | object | No | Optional configuration object. See fields below. |
| config.commitment | string | No | Desired finality level for the query. Accepted values: processed, confirmed, finalized (default). |
| config.epoch | u64 | No | Epoch for which the reward occurs. If omitted, the previous epoch is used. |
| config.minContextSlot | number | No | The minimum slot at which the request may be evaluated. |
commitment values
| Value | Description |
|---|---|
| processed | Return data from the highest slot this node has processed on the fork it currently considers best. This is the newest view, but it can still change if the cluster switches forks. |
| confirmed | Return data from the highest slot that at least two-thirds of active stake has directly voted to confirm. More stable than processed, but a weaker guarantee than finalized. |
| finalized | Return data from the highest slot that the cluster recognizes as finalized. The slot has reached maximum vote lockout in validators' vote towers and is recognized by at least two-thirds of active stake. This is the strongest commitment level. |
minContextSlot example
{ "minContextSlot": 341197000 }Response
response.jsonjson
{ "jsonrpc": "2.0", "result": [ { "epoch": 2, "effectiveSlot": 224, "amount": 2500, "postBalance": 499999442500, "commission": null }, null ], "id": 1}The result is a JSON array whose elements are either reward objects or null when no reward data is available for the corresponding input address.
| Field | Type | Description |
|---|---|---|
| epoch | u64 | Epoch for which the reward occurred. |
| effectiveSlot | u64 | The slot in which the rewards are effective. |
| amount | u64 | Reward amount in lamports. |
| postBalance | u64 | Post balance of the account in lamports after the reward was credited. |
| commission | u8 | null | Vote account commission when the reward was credited. null for staking rewards or if no commission applies. |