rootSubscribe
Subscribe to receive notification anytime a new root is set by the validator. This method establishes a persistent WebSocket connection that will send real-time notifications whenever the validator updates the root slot. The root represents the most recent slot that has been finalized and committed to the ledger. This subscription is useful for tracking the overall progress of the blockchain and understanding when transactions become irreversibly confirmed.
Request object for subscribing to root change notifications via WebSocket
JSON-RPC protocol version
2.0
Possible values: Request identifier that will be returned in the response
1
The WebSocket method name
rootSubscribe
Possible values: WebSocket notification for root changes
Subscription successfully created
Bad Request - Invalid parameters
Unauthorized
Forbidden
Too Many Requests
Internal Server Error
const ws = new WebSocket('wss://public.rpc.solanavibestation.com');
ws.onopen = function() {
// Subscribe to root notifications
ws.send(JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'rootSubscribe'
}));
};
ws.onmessage = function(event) {
const data = JSON.parse(event.data);
if (data.method === 'rootNotification') {
const rootSlot = data.params.result;
const subscriptionId = data.params.subscription;
console.log(`New root set at slot ${rootSlot} (subscription: ${subscriptionId})`);
} else if (data.result !== undefined) {
console.log('Root subscription ID:', data.result);
}
};
{
"jsonrpc": "2.0",
"method": "rootNotification",
"params": {
"result": 42,
"subscription": 0
}
}
Last updated