getEpochInfo
Returns information about the current epoch
Common use cases
| Calculate remaining time in current epoch | Poll getEpochInfo to get slotIndex and slotsInEpoch, then use getRecentPerformanceSamples to calculate average slot time. Multiply remaining slots (slotsInEpoch - slotIndex) by average slot time to estimate epoch completion time. Commonly used in staking UIs to display activation/deactivation timelines. |
| Validate blockhash expiry with blockHeight tracking | Poll getEpochInfo.blockHeight until it exceeds a blockhash's lastValidBlockHeight to confirm transaction expiry. Solana transactions expire after 150 blocks (~80 seconds), making blockHeight essential for monitoring transaction lifetime without repeatedly calling getSignatureStatuses. |
| Sync epoch boundaries for rewards calculation | Use getEpochInfo.epoch combined with getEpochSchedule to calculate first slot of current epoch, then fetch with getBlock to retrieve epoch start timestamps. Required for inflation rewards workflows where epoch-aligned data is needed (see getInflationReward integration). |
| Track network progression for validator operations | Monitor absoluteSlot and epoch fields to determine network health and sync status. Validators use this to verify they're tracking current epoch before performing epoch-sensitive operations like leader schedule queries or vote submissions. |
Parameters
config (object, optional)
Configuration object.
Fields:
commitment(string): The commitment describes how finalized a block is at that point in time. See Configuring State Commitment.minContextSlot(number): The minimum slot that the request can be evaluated at.
Request
- cURL
- JavaScript
- Python
curl https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getEpochInfo",
"params": [
{
"commitment": "finalized"
}
]
}'
// Using fetch
const response = await fetch('https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"method": "getEpochInfo",
"params": [
{
"commitment": "finalized"
}
]
})
});
const data = await response.json();
console.log(data);
import requests
import json
url = 'https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY'
headers = {'Content-Type': 'application/json'}
data = {
"jsonrpc": "2.0",
"id": 1,
"method": "getEpochInfo",
"params": [
{
"commitment": "finalized"
}
]
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
Replace mainnet with devnet in the URL to query devnet instead.
Response
{
"jsonrpc": "2.0",
"result": {
"absoluteSlot": 166598,
"blockHeight": 166500,
"epoch": 27,
"slotIndex": 2790,
"slotsInEpoch": 8192,
"transactionCount": 22661093
},
"id": 1
}
Response Fields
absoluteSlot (u64)
The current slot
blockHeight (u64)
The current block height
epoch (u64)
The current epoch
slotIndex (u64)
The current slot relative to the start of the current epoch
slotsInEpoch (u64)
The number of slots in this epoch
transactionCount (u64 | null)
Total number of transactions processed without error since genesis
FAQ and Troubleshooting
How do I calculate how much time is left in the current epoch?
Get slotsInEpoch and slotIndex from getEpochInfo, then fetch average slot time from getRecentPerformanceSamples. Calculate remaining slots as (slotsInEpoch - slotIndex), multiply by average slot time (~400ms on mainnet) to get seconds remaining.
What's the difference between absoluteSlot and slotIndex?
absoluteSlot is the total slot number since genesis (always increasing), while slotIndex is the slot's position within the current epoch (resets to 0 each epoch). Use slotIndex for epoch progress tracking, absoluteSlot for global ordering.
How often should I poll getEpochInfo for real-time updates?
For slot-level precision, poll every 400ms (slot duration). For epoch progress monitoring, poll every 30-60 seconds. Use slotSubscribe websocket method instead of polling for continuous real-time slot updates with lower RPC overhead.
Why does transactionCount sometimes return null?
transactionCount is null when the node hasn't calculated the total yet or doesn't track transaction counts. This is node implementation-specific and not guaranteed by the RPC spec. Don't rely on it for critical logic.
Can I use getEpochInfo to check if my blockhash expired?
Yes - track blockHeight from getEpochInfo and compare against your blockhash's lastValidBlockHeight. When blockHeight exceeds lastValidBlockHeight, the blockhash is expired and can no longer be used for transactions.
Related Methods
getEpochSchedule
Returns epoch schedule configuration including slots per epoch and warmup periods. Essential companion to getEpochInfo for calculating epoch boundaries and validating epoch progression logic.
getSlot
Returns current slot number (absoluteSlot). Use when only slot number is needed without full epoch context. Lighter alternative to getEpochInfo when slotIndex/slotsInEpoch aren't required.
getBlockHeight
Returns current block height. Alternative to getEpochInfo.blockHeight when only block number is needed for blockhash expiry validation without full epoch metadata.
getRecentPerformanceSamples
Returns performance metrics including average slot time. Required for accurate epoch time estimation by combining with getEpochInfo slot progress data.
getInflationReward
Returns inflation rewards for addresses at specific epochs. Commonly paired with getEpochInfo to determine current epoch for rewards queries and validate epoch boundaries for historical rewards.