getInflationReward
https://api.triport.io/v1/solReturns the inflation / staking reward earned by a list of addresses for a given Solana epoch.
getInflationReward returns the inflation (staking) reward credited to each of
a list of addresses for a single epoch. Each address in the request maps to one
entry in the returned array, in the same order as the input. The reward
amount is reported in lamports (1 SOL = 1,000,000,000 lamports), so divide
by 1e9 to display a SOL figure.
Only stake accounts and vote accounts earn inflation rewards. If an address is
not a reward-bearing account, or earned no reward for the requested epoch, its
slot in the result array is null. The array length always equals the number of
addresses you passed.
By default the reward for the previous epoch is returned. Pass epoch in
the config object to query a specific historical epoch. Note that nodes only
retain reward data for a limited window of recent epochs; very old epochs may no
longer be available.
Parameters
JSON-RPC params is a positional array: [addresses, config?].
addressesarray of string (base-58)required^[1-9A-HJ-NP-Za-km-z]{32,44}$.configobjectoptionalcommitmentstringoptionalprocessed, confirmed, or finalized.epochintegeroptionalminContextSlotintegeroptionalResponse
The first address earned a reward of 2500000 lamports (0.0025 SOL) for epoch
612. The second address is not a reward-bearing account for that epoch, so its
entry is null.
amountintegereffectiveSlotintegerepochintegerpostBalanceintegercommissionintegerErrors
Errors are returned in the standard JSON-RPC error envelope. See the shared errors reference for the full envelope shape and shared codes.
| Code | Meaning | When it happens |
|---|---|---|
-32602 | Invalid params | addresses is missing, contains an invalid base-58 string, or config is malformed. |
401 | Unauthorized | Missing or invalid Authorization: Bearer key. |
429 | Rate limited | More than your tier's RPS for sol_read_rpc (20 / 60 / 200 / 600). |
Examples
JavaScript (fetch)
const res = await fetch("https://api.triport.io/v1/sol", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "getInflationReward",
params: [
[
"6dmNQ5jwLeLk5REvio1JcMshcbvkYMwy26sJ8pbkvStu",
"BGsqMegLpV6n6Ve146sSX2dTjUMj3M92HnU8BbNRMhF2",
],
{ epoch: 612 },
],
}),
});
const { result } = await res.json();
result.forEach((reward, i) => {
if (reward === null) console.log(`address ${i}: no reward`);
else console.log(`address ${i}: ${reward.amount / 1e9} SOL @ epoch ${reward.epoch}`);
});TypeScript SDK (@triport/sdk)
import { TriportClient } from "@triport/sdk";
const client = new TriportClient({ apiKey: process.env.TRIPORT_API_KEY });
const rewards = await client.solana.getInflationReward(
[
"6dmNQ5jwLeLk5REvio1JcMshcbvkYMwy26sJ8pbkvStu",
"BGsqMegLpV6n6Ve146sSX2dTjUMj3M92HnU8BbNRMhF2",
],
{ epoch: 612 }
);
for (const [i, reward] of rewards.entries()) {
if (reward === null) console.log(`address ${i}: no reward`);
else console.log(`address ${i}: ${reward.amount / 1e9} SOL @ epoch ${reward.epoch}`);
}Python (triport-sdk)
import os
from triport import TriportClient
client = TriportClient(api_key=os.environ["TRIPORT_API_KEY"])
rewards = client.solana.get_inflation_reward(
[
"6dmNQ5jwLeLk5REvio1JcMshcbvkYMwy26sJ8pbkvStu",
"BGsqMegLpV6n6Ve146sSX2dTjUMj3M92HnU8BbNRMhF2",
],
epoch=612,
)
for i, reward in enumerate(rewards):
if reward is None:
print(f"address {i}: no reward")
else:
print(f"address {i}: {reward['amount'] / 1e9} SOL @ epoch {reward['epoch']}")Notes
- Order and length are preserved: the result array has exactly one entry per
requested address, in the same order. A
nullentry means that address earned no reward for the epoch (e.g. it is not a stake or vote account). - Lamports, not SOL:
amountandpostBalanceare integer lamport counts. Divide by1e9for a SOL figure. - Default epoch: when
epochis omitted, the reward for the previous epoch is returned. - History window: reward data is only retained for a limited number of
recent epochs; requests for very old epochs may return
null. - Related methods: use
getEpochInfoto discover the current epoch andgetInflationRatefor the cluster-wide inflation rate.