跳转到主要内容

参数

config
object
包含以下可选字段的配置对象:

响应

result
object

代码示例

基本请求

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": "getBlockProduction"
}'

带范围和身份的请求

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": "getBlockProduction",
  "params": [
    {
      "range": {
        "firstSlot": 100000000,
        "lastSlot": 100000100
      },
      "identity": "GH7ome3EiwEr17v3Fn6XY4RjS1YERxYzwXSW8kZ8kBYq"
    }
  ]
}'

使用 web3.js

import { Connection } from '@solana/web3.js';

const connection = new Connection('https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');

const blockProduction = await connection.getBlockProduction();
console.log('Block production:', blockProduction);

// Get production for specific range and validator
const config = {
  range: {
    firstSlot: 100000000,
    lastSlot: 100000100
  },
  identity: 'GH7ome3EiwEr17v3Fn6XY4RjS1YERxYzwXSW8kZ8kBYq'
};
const specificProduction = await connection.getBlockProduction(config);

注意事项

  1. 不带参数时,返回当前 epoch 中所有验证者的生产信息
  2. range 参数可以跨多个 epoch
  3. 区块生产统计用于跟踪验证者性能
  4. 结果包括分配的领导者 slot 和实际生产的区块

最佳实践

  1. 查询历史信息时使用 range 来限制数据
  2. 使用 identity 跟踪特定验证者性能
  3. 比较 leader_slotsblocks_produced 来评估验证者可靠性
  4. 适当时缓存结果以减少 RPC 负载

常见错误

错误码消息解决方案
-32602Invalid param: WrongSize验证验证者身份是否有效
-32602Invalid param: not base58 encoded string确保验证者身份是 base58 编码的
-32602Invalid param: slot range too large减小 slot 范围大小
-32007Block production not available节点可能正在启动或范围太旧