> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orbitflare.com/llms.txt
> Use this file to discover all available pages before exploring further.

# getEpochInfo

> 返回当前 epoch 的信息

## 参数

<ParamField query="commitment" type="string" optional>
  commitment 描述了区块在该时间点的最终确认程度。
</ParamField>

<ParamField query="minContextSlot" type="number" optional>
  请求可被评估的最小 slot。
</ParamField>

## 响应

<ResponseField name="result" type="object">
  <Expandable title="result fields">
    <ResponseField name="absoluteSlot" type="number">
      当前 slot
    </ResponseField>

    <ResponseField name="blockHeight" type="number">
      当前区块高度
    </ResponseField>

    <ResponseField name="epoch" type="number">
      当前 epoch
    </ResponseField>

    <ResponseField name="slotIndex" type="number">
      相对于当前 epoch 起始的当前 slot
    </ResponseField>

    <ResponseField name="slotsInEpoch" type="number">
      此 epoch 中的 slot 数量
    </ResponseField>

    <ResponseField name="transactionCount" type="number | null">
      自创世以来成功处理的交易总数
    </ResponseField>
  </Expandable>
</ResponseField>

## 代码示例

### 基本请求

```bash theme={null}
curl http://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getEpochInfo"
}'
```

### 使用 web3.js

```typescript theme={null}
import { Connection } from '@solana/web3.js';

const connection = new Connection('http://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');
const epochInfo = await connection.getEpochInfo();
console.log(epochInfo);
```

### 使用 Python

```python theme={null}
from solana.rpc.api import Client

client = Client("http://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY")
response = client.get_epoch_info()
print(response)
```

## 注意事项

1. 返回当前 epoch 的详细信息
2. 包括绝对 slot、区块高度、epoch 编号和 epoch 中的 slot 数
3. 交易计数如果不可用可能为 null
4. 可以指定不同的 commitment 级别
5. 响应是即时的，因为它从当前状态读取

## 最佳实践

1. 使用此方法跟踪 epoch 过渡
2. 监控交易计数以了解网络活动
3. 检查 slot 索引以确定当前 epoch 的进度
4. 适当处理网络错误并重试
5. 根据需求使用适当的 commitment 级别
