Updated on 2023-12-15 GMT+08:00

Examples

The eth_getFilterChange API is used as an example. Different from a single request, a batch request's request body encapsulates multiple sub-requests in arrays. The server returns the response of each sub-request in an array.

Example of a Single Request

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}'

Example of Batch Requests

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}]'

Return Value

Response arrays corresponding to each RPC call.

[{"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}]