subscribeNewBlock - Dogecoin
Example code for the subscribeNewBlock WebSocket method. Complete guide on how to use the subscribeNewBlock WebSocket method in the GetBlock Web3 documentation.
Subscribes to new blocks. The server pushes the height and hash of each block as it is connected to the chain. Combined with a transaction's own block height, this is how confirmation depth is tracked without polling.
Parameters
This method takes no parameters. Send an empty params object.
Message
wscat -c wss://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>
# then send:
{
"id": "newblock",
"method": "subscribeNewBlock",
"params": {}
}Response
{
"id": "newblock",
"data": {
"subscribed": true
}
}Notifications
While subscribed, the server pushes one message per connected block:
Response Fields
subscribed
boolean
Confirms the subscription is active
height
integer
Height of the newly connected block (in notifications)
hash
string
Hash of the newly connected block (in notifications)
Use Cases
Confirmation Counting: Compute depth as the new height minus a transaction's block height, plus one
Settlement Triggers: Release an order once a deposit reaches the required depth
Chain Tip Tracking: Keep a local view of the best height current
Cache Invalidation: Refresh indexed data when a block arrives
Error Handling
403 / RBAC: access denied
Access denied
The GetBlock access token is missing or incorrect
Last updated
Was this helpful?