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_blockNumber | 1 |
eth_chainId | 1 |
eth_getBlockByNumber | 5 |
eth_blobBaseFee | 10 |
eth_feeHistory | 10 |
eth_gasPrice | 10 |
eth_getBalance | 10 |
eth_getBlockByHash | 10 |
eth_getBlockReceipts | 10 |
eth_getBlockTransactionCountByHash | 10 |
eth_getBlockTransactionCountByNumber | 10 |
eth_getCode | 10 |
eth_getHeaderByHash | 10 |
eth_getHeaderByNumber | 10 |
eth_getProof | 10 |
eth_getRawTransactionByBlockHashAndIndex | 10 |
eth_getRawTransactionByBlockNumberAndIndex | 10 |
eth_getRawTransactionByHash | 10 |
eth_getStorageAt | 10 |
eth_getTransactionByBlockHashAndIndex | 10 |
eth_getTransactionByBlockNumberAndIndex | 10 |
eth_getTransactionByHash | 10 |
eth_getTransactionCount | 10 |
eth_getTransactionReceipt | 10 |
eth_getUncleByBlockHashAndIndex | 10 |
eth_getUncleByBlockNumberAndIndex | 10 |
eth_getUncleCountByBlockHash | 10 |
eth_getUncleCountByBlockNumber | 10 |
eth_maxPriorityFeePerGas | 10 |
eth_syncing | 10 |
net_version | 10 |
web3_clientVersion | 10 |
web3_sha3 | 10 |
eth_call | 15 |
eth_createAccessList | 20 |
eth_estimateGas | 20 |
eth_simulateV1 | 20 |
eth_getLogs | 30 |
eth_sendRawTransaction | 30 |
debug_traceBlockByHash | 100 |
debug_traceBlockByNumber | 100 |
debug_traceCall | 100 |
debug_traceTransaction | 100 |
trace_block | 100 |
trace_call | 100 |
trace_get | 100 |
trace_replayTransaction | 100 |
trace_transaction | 100 |
方法策略
可用方法因鏈而異,下面按鏈分別列出,其他說明見支援的鏈。只有符合允許的方法名或模式的方法才可呼叫,其他方法傳回 -32601 method not available。
以下各鏈均允許
eth_blockNumbereth_calleth_chainIdeth_estimateGaseth_feeHistoryeth_gasPriceeth_getBalanceeth_getBlockByHasheth_getBlockByNumbereth_getBlockReceiptseth_getBlockTransactionCountByHasheth_getBlockTransactionCountByNumbereth_getCodeeth_getLogseth_getStorageAteth_getTransactionByBlockHashAndIndexeth_getTransactionByBlockNumberAndIndexeth_getTransactionByHasheth_getTransactionCounteth_getTransactionReceipteth_maxPriorityFeePerGaseth_syncingnet_versionweb3_clientVersion
Arbitrum One
eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗 6,000 個區塊
另外允許
debug_traceBlockByHashdebug_traceBlockByNumberdebug_traceCalldebug_traceTransactioneth_blobBaseFeeeth_createAccessListeth_getHeaderByHasheth_getHeaderByNumbereth_getProofeth_getRawTransactionByBlockHashAndIndexeth_getRawTransactionByBlockNumberAndIndexeth_getRawTransactionByHasheth_getUncleByBlockHashAndIndexeth_getUncleByBlockNumberAndIndexeth_getUncleCountByBlockHasheth_getUncleCountByBlockNumbereth_sendRawTransactioneth_simulateV1web3_sha3
Base
eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗 10,000 個區塊
另外允許
eth_blobBaseFeeeth_createAccessListeth_getProofeth_simulateV1eth_getRawTransactionByHasheth_getRawTransactionByBlockHashAndIndexeth_getRawTransactionByBlockNumberAndIndexeth_getUncleCountByBlockNumbereth_getUncleCountByBlockHasheth_getUncleByBlockNumberAndIndexeth_getUncleByBlockHashAndIndexeth_getHeaderByNumbereth_getHeaderByHasheth_sendRawTransactionweb3_sha3
BNB Smart Chain
eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗 100 個區塊
另外允許
eth_sendRawTransaction
以太坊
eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗 250,000 個區塊
另外允許
debug_traceBlockByHashdebug_traceBlockByNumberdebug_traceCalldebug_traceTransactioneth_blobBaseFeeeth_createAccessListeth_getProofeth_sendRawTransactiontrace_blocktrace_calltrace_gettrace_replayTransactiontrace_transactionweb3_sha3
Ethereum Sepolia
eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗:—
另外允許
eth_blobBaseFeeeth_createAccessListeth_getProofeth_sendRawTransactionweb3_sha3
HyperEVM
該鏈暫不支援傳送交易(eth_sendRawTransaction 傳回 -32601 method_not_allowed),讀取方法正常。
eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗:—
Polygon
eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗 126 個區塊
另外允許
debug_traceBlockByHashdebug_traceBlockByNumberdebug_traceCalldebug_traceTransactioneth_blobBaseFeeeth_createAccessListeth_getHeaderByHasheth_getHeaderByNumbereth_getProofeth_getRawTransactionByBlockHashAndIndexeth_getRawTransactionByBlockNumberAndIndexeth_getRawTransactionByHasheth_getUncleByBlockHashAndIndexeth_getUncleByBlockNumberAndIndexeth_getUncleCountByBlockHasheth_getUncleCountByBlockNumbereth_sendRawTransactioneth_simulateV1web3_sha3
Robinhood Chain
eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗 900 個區塊
另外允許
eth_blobBaseFeeeth_createAccessListeth_getProofeth_simulateV1eth_getRawTransactionByHasheth_getRawTransactionByBlockHashAndIndexeth_getRawTransactionByBlockNumberAndIndexeth_getUncleCountByBlockNumbereth_getUncleCountByBlockHasheth_getUncleByBlockNumberAndIndexeth_getUncleByBlockHashAndIndexeth_getHeaderByNumbereth_getHeaderByHasheth_sendRawTransactionweb3_sha3debug_traceTransactiondebug_traceCalldebug_traceBlockByNumberdebug_traceBlockByHash
Robinhood Chain Testnet
eth_getLogs 單次最大區塊跨度 1,000 個區塊;狀態視窗 1,023 個區塊
另外允許
debug_traceBlockByHashdebug_traceBlockByNumberdebug_traceCalldebug_traceTransactioneth_blobBaseFeeeth_createAccessListeth_getHeaderByHasheth_getHeaderByNumbereth_getProofeth_getRawTransactionByBlockHashAndIndexeth_getRawTransactionByBlockNumberAndIndexeth_getRawTransactionByHasheth_getUncleByBlockHashAndIndexeth_getUncleByBlockNumberAndIndexeth_getUncleCountByBlockHasheth_getUncleCountByBlockNumbereth_sendRawTransactioneth_simulateV1web3_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 參考。
最後更新: