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.
此方法不接受任何参数。
代码示例
基本请求
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": "getFirstAvailableBlock"
}'
使用 web3.js
import { Connection } from '@solana/web3.js';
const connection = new Connection('https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');
// Get first available block
const firstBlock = await connection.getFirstAvailableBlock();
console.log('First available block:', firstBlock);
// Get block range
async function getAvailableBlockRange() {
const firstBlock = await connection.getFirstAvailableBlock();
const currentSlot = await connection.getSlot();
return {
firstBlock,
currentSlot,
totalBlocks: currentSlot - firstBlock + 1
};
}
注意事项
- 返回可用的最低已确认区块的 slot
- 这对于确定节点的可用历史记录很有用
- 随着节点修剪旧区块,该值可能会变化
- 不同节点可能返回不同的值
- 响应是即时的,因为它从当前状态读取
最佳实践
- 使用此方法确定可用的区块范围
- 查询历史区块时考虑节点修剪
- 适当时缓存结果以减少 RPC 负载
- 处理请求的区块不可用的情况
- 与其他区块方法结合使用
常见错误
| 错误码 | 消息 | 解决方案 |
|---|
| -32601 | Method not found | 验证是否连接到 Solana RPC 节点 |
| -32007 | Block information unavailable | 节点可能正在启动或同步中 |