chain_subscribeAllHeads
Retrieves the newest header via subscription.
Clients can create a subscription to get updates on the newest block headers as they are created using the chain_subscribeAllHeads function. Apps that require real-time information on new blocks added to the blockchain depend on this constant flow of data. With the subscription system, clients are updated quickly and don't have to poll the network frequently.
Example Request and Result for chain_subscribeAllHeads method
In this section, we provide an illustrative example of a request made to retrieve details contents using the chain_subscribeAllHeads
method. Additionally, we present the resulting response containing information about getting the newest header using WS subscription.
Parameters
Fields | Type | Description |
---|---|---|
subscription | string | Manages the subscription to header updates. |
The example in this section uses a non-existing project id.
Make sure you replace it with your Vara Mainnet endpoint when issuing the API calls.
Don't have a project id? Here's a straightforward guide on how to obtain one!
Retrieves the newest header via subscription.
POST
wss://vara-mainnet.blastapi.io/<project-id>
Request Body
Name | Type | Description |
---|---|---|
subscription | string | [] |
- 200: OK Expand for a detailed response example
{
"jsonrpc": "2.0",
"method": "chain_allHead",
"params": {
"subscription": "GP0sH6g9qR8lQEmD",
"result": {
"parentHash": "0xcb66928b4ad7b7855f6aaec981c0025620bc1e834f9b15f082e24b5ac9d0b609",
"number": "0x99c5b8",
"stateRoot": "0xf7d74721a9b1d545d444f9aef703a14f4741b4ea739f47d751337ad3ab6b1d71",
"extrinsicsRoot": "0x6c30cc0fa254a472cdb5a7068cdd46ee4d5e2a3c0dfa84de001ca893d7b9a405",
"digest": {
"logs": [
"0x064241424534022e0000000ea1f82100000000",
"0x0542414245010106597c16765f403715d456eecfe7839c562fb7c2f073739deae1a30d326a3b4713db10b808bbd4b661bf0b13c1f72b98814f55f58a3b969fd430c52e6fbd668b"
]
}
}
}
}
Curl Request example
wscat -c 'wss://vara-mainnet.blastapi.io/<project-id>'
# wait for connection
messasge:
{
"id": 1,
"jsonrpc": "2.0",
"method": "chain_subscribeAllHeads",
"params": []
}