JSON-RPC

JSON-RPC

各鏈支援的 JSON-RPC 方法、CU 權重與錯誤碼。本頁介紹接入方式、方法清單、按鏈可用性、限流與計費規則,以及常見錯誤的處理方式。

概述

所有請求按 Compute Units(CU) 計量,並按 key 進行速率限制。

  • 端點:POST /v1/{chain}/{api_key}(key 放在路徑中)或 POST /v1/{chain}(key 放在請求標頭中)。Robinhood Chain 的 {chain} 是 robinhood_mainnet:https://api.blockvectra.com/v1/robinhood_mainnet。同一個 API key 可用於所有已支援的鏈
  • 協定:HTTP POST,單個呼叫或批次
  • 計量:請求到達時,其全部 CU 開銷立即計入該 key 的突發容量;每個被受理並得到回應的呼叫按該方法公布的 CU 權重計費,不計費的情況見錯誤參考。按小時帳期結算扣費(向下取整為整單位,餘數結轉下一期,帳期結束約 15 分鐘後執行)
  • 以太坊:有自己的方法清單,狀態視窗以 state_window_blocks 為準,見支援的鏈 → 以太坊。

關於全部方法的完整參數 schema、方法簽名與互動式測試,請參閱完整參考。關於路徑版本、回溯相容規則與對接建議,請參閱 API 版本控制與相容性。

取得 API key 與發出第一個請求見快速入門,其中也說明了 key 的傳遞方式與批次請求。

常用呼叫範例

常用呼叫的完整範例。

日誌查詢(eth_getLogs)

按合約地址和 topic 過濾最近一段區塊的日誌——這裡以 ERC-20 的 Transfer 事件(topic 為 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef)為例。eth_getLogs 的目前 CU 權重見下方CU 計量規則表;區塊跨度超過該鏈 max_logs_block_range(取自 GET /v1/chains)的請求會被拒絕並傳回 -32602。

export BLOCKVECTRA_API_KEY=rgw_your_api_key

curl -X POST "https://api.blockvectra.com/v1/robinhood_mainnet" \
  -H 'Content-Type: application/json' \
  -H "x-api-key: $BLOCKVECTRA_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [{
      "fromBlock": "0x45a2409",
      "toBlock": "0x45a2609",
      "address": "0x1111111111111111111111111111111111111111",
      "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
    }],
    "id": 1
  }'

交易 Trace(debug_traceTransaction)

用 callTracer 追蹤一筆交易的內部呼叫。debug_traceTransaction 的目前 CU 權重見下方CU 計量規則表。和其他讀取狀態的方法一樣,目標區塊若超出該鏈的近期狀態視窗就會被拒絕(-32011)。視窗大小為該鏈的 state_window_blocks(取自 GET /v1/chains)。在提供 trace 的鏈上,歷史 trace 請使用 Data API。

export BLOCKVECTRA_API_KEY=rgw_your_api_key

curl -X POST "https://api.blockvectra.com/v1/robinhood_mainnet" \
  -H 'Content-Type: application/json' \
  -H "x-api-key: $BLOCKVECTRA_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "method": "debug_traceTransaction",
    "params": ["0xYOUR_TRANSACTION_HASH", {"tracer": "callTracer"}],
    "id": 1
  }'

CU 計量規則

各 JSON-RPC 方法的計算單位(CU)權重。

方法名權重(CU)
eth_blockNumber1
eth_chainId1
eth_getBlockByNumber5
eth_blobBaseFee10
eth_feeHistory10
eth_gasPrice10
eth_getBalance10
eth_getBlockByHash10
eth_getBlockReceipts10
eth_getBlockTransactionCountByHash10
eth_getBlockTransactionCountByNumber10
eth_getCode10
eth_getHeaderByHash10
eth_getHeaderByNumber10
eth_getProof10
eth_getRawTransactionByBlockHashAndIndex10
eth_getRawTransactionByBlockNumberAndIndex10
eth_getRawTransactionByHash10
eth_getStorageAt10
eth_getTransactionByBlockHashAndIndex10
eth_getTransactionByBlockNumberAndIndex10
eth_getTransactionByHash10
eth_getTransactionCount10
eth_getTransactionReceipt10
eth_getUncleByBlockHashAndIndex10
eth_getUncleByBlockNumberAndIndex10
eth_getUncleCountByBlockHash10
eth_getUncleCountByBlockNumber10
eth_maxPriorityFeePerGas10
eth_syncing10
net_version10
web3_clientVersion10
web3_sha310
eth_call15
eth_createAccessList20
eth_estimateGas20
eth_simulateV120
eth_getLogs30
eth_sendRawTransaction30
debug_traceBlockByHash100
debug_traceBlockByNumber100
debug_traceCall100
debug_traceTransaction100
trace_block100
trace_call100
trace_get100
trace_replayTransaction100
trace_transaction100

方法策略

可用方法因鏈而異,下面按鏈分別列出,其他說明見支援的鏈。只有符合允許的方法名或模式的方法才可呼叫,其他方法傳回 -32601 method not available。

以下各鏈均允許

  • eth_blockNumber
  • eth_call
  • eth_chainId
  • eth_estimateGas
  • eth_feeHistory
  • eth_gasPrice
  • eth_getBalance
  • eth_getBlockByHash
  • eth_getBlockByNumber
  • eth_getBlockReceipts
  • eth_getBlockTransactionCountByHash
  • eth_getBlockTransactionCountByNumber
  • eth_getCode
  • eth_getLogs
  • eth_getStorageAt
  • eth_getTransactionByBlockHashAndIndex
  • eth_getTransactionByBlockNumberAndIndex
  • eth_getTransactionByHash
  • eth_getTransactionCount
  • eth_getTransactionReceipt
  • eth_maxPriorityFeePerGas
  • eth_syncing
  • net_version
  • web3_clientVersion

Arbitrum One

eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗 6,000 個區塊

另外允許

  • debug_traceBlockByHash
  • debug_traceBlockByNumber
  • debug_traceCall
  • debug_traceTransaction
  • eth_blobBaseFee
  • eth_createAccessList
  • eth_getHeaderByHash
  • eth_getHeaderByNumber
  • eth_getProof
  • eth_getRawTransactionByBlockHashAndIndex
  • eth_getRawTransactionByBlockNumberAndIndex
  • eth_getRawTransactionByHash
  • eth_getUncleByBlockHashAndIndex
  • eth_getUncleByBlockNumberAndIndex
  • eth_getUncleCountByBlockHash
  • eth_getUncleCountByBlockNumber
  • eth_sendRawTransaction
  • eth_simulateV1
  • web3_sha3

Base

eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗 10,000 個區塊

另外允許

  • eth_blobBaseFee
  • eth_createAccessList
  • eth_getProof
  • eth_simulateV1
  • eth_getRawTransactionByHash
  • eth_getRawTransactionByBlockHashAndIndex
  • eth_getRawTransactionByBlockNumberAndIndex
  • eth_getUncleCountByBlockNumber
  • eth_getUncleCountByBlockHash
  • eth_getUncleByBlockNumberAndIndex
  • eth_getUncleByBlockHashAndIndex
  • eth_getHeaderByNumber
  • eth_getHeaderByHash
  • eth_sendRawTransaction
  • web3_sha3

BNB Smart Chain

eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗 100 個區塊

另外允許

  • eth_sendRawTransaction

以太坊

eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗 250,000 個區塊

另外允許

  • debug_traceBlockByHash
  • debug_traceBlockByNumber
  • debug_traceCall
  • debug_traceTransaction
  • eth_blobBaseFee
  • eth_createAccessList
  • eth_getProof
  • eth_sendRawTransaction
  • trace_block
  • trace_call
  • trace_get
  • trace_replayTransaction
  • trace_transaction
  • web3_sha3

Ethereum Sepolia

eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗:—

另外允許

  • eth_blobBaseFee
  • eth_createAccessList
  • eth_getProof
  • eth_sendRawTransaction
  • web3_sha3

HyperEVM

該鏈暫不支援傳送交易(eth_sendRawTransaction 傳回 -32601 method_not_allowed),讀取方法正常。

eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗:—

Polygon

eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗 126 個區塊

另外允許

  • debug_traceBlockByHash
  • debug_traceBlockByNumber
  • debug_traceCall
  • debug_traceTransaction
  • eth_blobBaseFee
  • eth_createAccessList
  • eth_getHeaderByHash
  • eth_getHeaderByNumber
  • eth_getProof
  • eth_getRawTransactionByBlockHashAndIndex
  • eth_getRawTransactionByBlockNumberAndIndex
  • eth_getRawTransactionByHash
  • eth_getUncleByBlockHashAndIndex
  • eth_getUncleByBlockNumberAndIndex
  • eth_getUncleCountByBlockHash
  • eth_getUncleCountByBlockNumber
  • eth_sendRawTransaction
  • eth_simulateV1
  • web3_sha3

Robinhood Chain

eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗 900 個區塊

另外允許

  • eth_blobBaseFee
  • eth_createAccessList
  • eth_getProof
  • eth_simulateV1
  • eth_getRawTransactionByHash
  • eth_getRawTransactionByBlockHashAndIndex
  • eth_getRawTransactionByBlockNumberAndIndex
  • eth_getUncleCountByBlockNumber
  • eth_getUncleCountByBlockHash
  • eth_getUncleByBlockNumberAndIndex
  • eth_getUncleByBlockHashAndIndex
  • eth_getHeaderByNumber
  • eth_getHeaderByHash
  • eth_sendRawTransaction
  • web3_sha3
  • debug_traceTransaction
  • debug_traceCall
  • debug_traceBlockByNumber
  • debug_traceBlockByHash

Robinhood Chain Testnet

eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗 1,023 個區塊

另外允許

  • debug_traceBlockByHash
  • debug_traceBlockByNumber
  • debug_traceCall
  • debug_traceTransaction
  • eth_blobBaseFee
  • eth_createAccessList
  • eth_getHeaderByHash
  • eth_getHeaderByNumber
  • eth_getProof
  • eth_getRawTransactionByBlockHashAndIndex
  • eth_getRawTransactionByBlockNumberAndIndex
  • eth_getRawTransactionByHash
  • eth_getUncleByBlockHashAndIndex
  • eth_getUncleByBlockNumberAndIndex
  • eth_getUncleCountByBlockHash
  • eth_getUncleCountByBlockNumber
  • eth_sendRawTransaction
  • eth_simulateV1
  • web3_sha3

限制:

  • 批次:每個請求最多 100 個呼叫;同時受該 key 的 CU 突發容量限制,見下文。
  • 請求主體:最大 2 MiB
  • CU 突發:每個 API key 均有 CU 權杖貯體(cu_per_sec 補充速率、burst_cu 突發容量——預設 400 CU/s、突發 1,600 CU;在控制台 Keys 表按 key 顯示)。單個請求(包括整批 JSON-RPC 批次呼叫)的 CU 總開銷若超過該 key 的突發容量,會被拒絕並傳回 -32022 request_exceeds_burst(request cost <N> CU exceeds burst capacity <M> CU);請拆分為更小的批次。

錯誤碼表

全部錯誤碼、是否計費與處理方式見錯誤參考。

完整 OpenAPI 參考

完整的機器可讀規範(含所有方法簽名、請求與回應 schema 及互動式參數詳情)見完整 OpenAPI 參考。

最後更新:

本頁目錄