更新时间:2023-12-11 GMT+08:00

批量请求示例

以eth_getFilterChange接口为例,批量请求和单个请求的区别是请求body以数组形式包装多个子请求。服务端以数组形式包装返回各子请求的响应。

单个请求示例

curl https://your-http-endpoint/v1/<API-KEY> \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0x16"],"id":1}'

批量请求示例

curl https://your-http-endpoint/v1/<API-KEY> \
    -X POST \
    -H "Content-Type: application/json" \
    -d '[{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0x16"],"id":1},
{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0x16"],"id":2},
{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0x16"],"id":3},
{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0x16"],"id":4}]'

返回值

各个RPC调用对应的响应数组。

[{"jsonrpc":"2.0","id":1,"result":null},{"jsonrpc":"2.0","id":2,"result":null},{"jsonrpc":"2.0","id":3,"result":null},{"jsonrpc":"2.0","id":4,"result":null}]