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.
包含以下可选字段的配置对象:
使用的 commitment 级别:
processed:最新区块(未确认)
confirmed:超级多数确认
finalized:超级多数最终确认
代码示例
基本请求
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlocksWithLimit",
"params": [
100000000,
10
]
}'
带 Commitment 的请求
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlocksWithLimit",
"params": [
100000000,
10,
{
"commitment": "finalized"
}
]
}'
使用 web3.js
import { Connection } from '@solana/web3.js';
const connection = new Connection('https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');
// Get 10 blocks starting from slot
const blocks = await connection.getBlocksWithLimit(100000000, 10);
console.log('Blocks:', blocks);
// Get finalized blocks
const finalizedBlocks = await connection.getBlocksWithLimit(100000000, 10, 'finalized');
console.log('Finalized blocks:', finalizedBlocks);
注意事项
- 返回从指定 slot 开始的已确认区块
- 结果按升序返回
- limit 控制返回的最大区块数
- 某些 slot 可能被跳过(未生产区块)
- 响应是即时的,因为它从当前状态读取
最佳实践
- 根据需求使用适当的 commitment 级别
- 保持 limit 合理以避免超时
- 使用此方法代替
getBlocks 进行分页
- 适当时缓存结果以减少 RPC 负载
- 在应用逻辑中处理跳过的 slot
常见错误
| 错误码 | 消息 | 解决方案 |
|---|
| -32602 | Invalid param: limit must be positive | 确保 limit 大于 0 |
| -32602 | Invalid param: limit too large | 减小 limit 大小 |
| -32601 | Method not found | 验证是否连接到 Solana RPC 节点 |
| -32007 | Block information unavailable | 节点可能正在启动或 slot 太旧 |