getEpochInfo

Returns information about the current epoch, including the epoch number, slot index within the epoch, the number of slots in the epoch, total absolute slot, and current block height. This method is essential for staking UIs, validator dashboards, and any application that needs to understand where the network is in its epoch cycle for reward calculations and stake activation timing.

Parameters

#TypeRequiredDescription
1objectNoConfiguration object

Configuration object fields:

FieldTypeDescription
commitmentstringCommitment level: processed, confirmed, or finalized
minContextSlotnumberMinimum slot at which the request can be evaluated

Response

Returns an object:

FieldTypeDescription
absoluteSlotu64The current slot
blockHeightu64The current block height
epochu64The current epoch
slotIndexu64The current slot relative to the start of the current epoch
slotsInEpochu64The number of slots in this epoch
transactionCount`u64null`

Code Examples

cURL

1curl http://[IP_ADDRESS]:[PORT] -X POST -H "Content-Type: application/json" -d '{
2  "jsonrpc": "2.0",
3  "id": 1,
4  "method": "getEpochInfo",
5  "params": [
6    { "commitment": "finalized" }
7  ]
8}'

TypeScript

1const response = await fetch("http://[IP_ADDRESS]:[PORT]", {
2  method: "POST",
3  headers: { "Content-Type": "application/json" },
4  body: JSON.stringify({
5    jsonrpc: "2.0",
6    id: 1,
7    method: "getEpochInfo",
8    params: [
9      { commitment: "finalized" }
10    ]
11  }),
12});
13const { result } = await response.json();
14console.log("Epoch:", result.epoch, "Progress:", (result.slotIndex / result.slotsInEpoch * 100).toFixed(1) + "%");

Python

1import requests
2
3response = requests.post("http://[IP_ADDRESS]:[PORT]", json={
4    "jsonrpc": "2.0",
5    "id": 1,
6    "method": "getEpochInfo",
7    "params": [
8        {"commitment": "finalized"}
9    ]
10})
11result = response.json()["result"]
12print(f"Epoch: {result['epoch']}, Progress: {result['slotIndex']/result['slotsInEpoch']*100:.1f}%")

Rust

1use reqwest::Client;
2use serde_json::json;
3
4#[tokio::main]
5async fn main() -> Result<(), Box<dyn std::error::Error>> {
6    let client = Client::new();
7    let res = client.post("http://[IP_ADDRESS]:[PORT]")
8        .json(&json!({
9            "jsonrpc": "2.0",
10            "id": 1,
11            "method": "getEpochInfo",
12            "params": [
13                {"commitment": "finalized"}
14            ]
15        }))
16        .send().await?
17        .text().await?;
18    println!("{}", res);
19    Ok(())
20}

Example Response

1{
2  "jsonrpc": "2.0",
3  "result": {
4    "absoluteSlot": 166974442,
5    "blockHeight": 150676031,
6    "epoch": 385,
7    "slotIndex": 246442,
8    "slotsInEpoch": 432000,
9    "transactionCount": 168032549921
10  },
11  "id": 1
12}