> ## 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.

# getBlockCommitment

> 返回特定区块的 commitment 信息

## 参数

<ParamField query="slot" type="number" required>
  区块编号，由 Slot 标识
</ParamField>

## 响应

<ResponseField name="result" type="object">
  <Expandable title="result fields">
    <ResponseField name="commitment" type="array | null">
      u64 整数数组，记录从深度 0 到 `MAX_LOCKOUT_HISTORY` 的每个深度上对该区块投票的集群质押量（以 lamports 为单位）。
    </ResponseField>

    <ResponseField name="totalStake" type="number">
      当前 epoch 的总活跃质押量，以 lamports 为单位。
    </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": "getBlockCommitment",
  "params": [5]
}'
```

### 使用 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 commitment = await connection.getBlockCommitment(5);
console.log(commitment);
```

### 使用 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_block_commitment(5)
print(response)
```

## 注意事项

1. 返回特定区块的 commitment 信息
2. commitment 数组表示质押权重分布
3. totalStake 值代表当前 epoch 的总活跃质押量
4. 响应是即时的，因为它从当前状态读取

## 最佳实践

1. 使用此方法验证区块确认状态
2. 比较 commitment 值以了解共识级别
3. 适当处理网络错误并重试
