# getEpochInfo

The `getEpochInfo` RPC method returns real-time information about the **current epoch** on the Solana network. It helps track **epoch progression**, **network state**, and can be used to determine how far the network has advanced into the current epoch and when the next epoch is expected to begin.

***

#### ✅ Common Use Cases

* **Monitor Epoch Progression**\
  Retrieve the current slot index within the epoch and total slots in the epoch to estimate time remaining.
* **Analyze Network State**\
  Access core metrics like epoch number, block height, and transactions processed to evaluate network activity.
* **Node Synchronization Checks**\
  Confirm whether a node is aligned with the network by comparing its epoch info against a trusted source.

***

#### 🛠 Request Parameters

`getEpochInfo` optionally accepts a configuration object:

* **`commitment`** (*string, optional*):\
  Defines the ledger confirmation level:
  * `finalized` *(default)* – Highest safety; may lag slightly.
  * `confirmed` – Recently voted on by supermajority.
  * `processed` – Fastest, but may be incomplete or rollback-prone.
* **`minContextSlot`** (*number, optional*):\
  Ensures the response is evaluated at or beyond a specific slot, useful for timeline-sensitive consistency.

***

#### 📦 Response Structure

The `result` field will return an object containing:

| Field              | Type          | Description                                                         |
| ------------------ | ------------- | ------------------------------------------------------------------- |
| `absoluteSlot`     | *u64*         | Current absolute slot number on the ledger.                         |
| `blockHeight`      | *u64*         | Current block height (number of blocks produced since genesis).     |
| `epoch`            | *u64*         | Current epoch number.                                               |
| `slotIndex`        | *u64*         | Current slot within the epoch.                                      |
| `slotsInEpoch`     | *u64*         | Total slots assigned to the current epoch.                          |
| `transactionCount` | *u64 \| null* | Total number of transactions processed in this epoch (may be null). |

***

#### 💡 Examples

**1. Fetch Epoch Info with Default Commitment**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getEpochInfo"
}
```

2\. **Fetch Epoch Info Using `confirmed` Commitment**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getEpochInfo",
  "params": [
    {
      "commitment": "confirmed"
    }
  ]
}
```

**Code Examples**

{% tabs %}
{% tab title="Nodejs" %}

```javascript
const fetch = require('node-fetch');

async function getEpochInfo(rpcUrl) {
  try {
    const response = await fetch(rpcUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'getEpochInfo'
      }),
    });

    const data = await response.json();
    
    // Print the exact full response
    console.log('Full RPC Response:');
    console.log(JSON.stringify(data, null, 2));
    
    return data;
  } catch (error) {
    console.error('Error getting health:', error.message);
    return null;
  }
}

// Example usage
const RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key';

getEpochInfo(RPC_URL);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

def get_epoch_info(rpc_url):
    try:
        response = requests.post(
            rpc_url,
            headers={
                'Content-Type': 'application/json',
            },
            json={
                'jsonrpc': '2.0',
                'id': 1,
                'method': 'getEpochInfo'
            }
        )
        
        data = response.json()
        
        # Print the exact full response
        print('Full RPC Response:')
        print(json.dumps(data, indent=2))
        
        return data
        
    except Exception as error:
        print(f'Error getting health: {error}')
        return None

# Example usage
RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key'
get_epoch_info(RPC_URL)
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "jsonrpc": "2.0",
  "result": {
    "absoluteSlot": 355253587,
    "blockHeight": 333445451,
    "epoch": 822,
    "slotIndex": 149587,
    "slotsInEpoch": 432000,
    "transactionCount": 429927746973
  },
  "id": 1
}
```

#### 🧠 Developer Tips

* **Choosing Commitment Levels**\
  Use `finalized` for highest confidence. Use `processed` for low-latency monitoring. For balanced needs, `confirmed` is a good compromise.
* **Transaction Count Limitations**\
  `transactionCount` may be `null` if not tracked by the node or unavailable for the specified commitment level.
* **Dynamic Epoch Lengths**\
  `slotsInEpoch` can vary based on network configuration. Use `getEpochSchedule` to explore the full epoch schedule and slot structure.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coinvera.io/integration/solana/rpc/getepochinfo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
