Anatomy of a request
Explore the anatomy of a JSON RPC request in the Blast SDK.
JSON RPC
JSON RPC is a remote procedure call that uses JSON for call serialization. A method call looks like this:
Object | Explanation |
---|---|
{ | |
"jsonrpc": "2.0", | Specifies the version of JSON RPC. All our APIs use version 2.0. |
"id": 1, | The id of the method call. This field does not exist for notifications. The response from the server will return the same id as used for the call. |
"method": "add", | The name of the method to call on the server. |
"params": [1, 2] | The parameters to pass to the method call. |
} |
Batch call
JSON RPC also supports batches of calls:
[
{
"jsonrpc": "2.0",
"id": 0,
"method": "add",
"params": [1, 2]
},
{
"jsonrpc": "2.0",
"id": 1,
"method": "subtract",
"params": [2, 1]
}
]
An example of the response one might expect from the call above is:
[
{
"jsonrpc": "2.0",
"id": 1,
"result": 1
},
{
"jsonrpc": "2.0",
"id": 0,
"result": 3
}
]
As can be seen, the order of the responses does not need to follow the same order the the request had so the id
field is used to match the results to the requests.
Notifications
The JSON RPC protocol also supports notifications. These are basically responses that were not triggered by a method call. The only difference from a traditional response is that they don't have an id
field:
{
"jsonrpc": "2.0",
"method": "subscription",
"params": [
"subscription": "0xdeadbeef",
"changed": "something"
]
}
Method calls and request limits
Each method call is counted as a request against your Blast API plan. This means that if you choose to use batch calls with 10 calls each then each such batch will be counted as 10 requests.
Additionally, since the notifications are not triggered by a method call but consume server resources, they are also counted as requests using the following formula:
For example, if you get a notification of 1.4 KB, then the number of requests will be
1433.6 / 500 = 2.8672 ~= 3
So this notification will count as 3 requests against your Blast API plan.
REST
While most of the endpoints available through the Blast API use JSON RPC, there are two networks that use REST as a protocol. These are elrond-mainnet
and elrond-testnet
. For these two networks, the requests billed against your Blast API plan are mapped 1-1 with the HTTP requests made against the endpoints.