Skip to main content

rootSubscribe RPC Method

(Subscription Websocket) Subscribe to receive notification anytime a new root is set by the validator.

Updated on
Oct 4, 2023

rootSubscribe RPC Method

Parameters

This method does not accept any parameters

Returns

result
integer
The result will be an RpcResponse JSON object with id equal to the subscription id (needed to unsubscribe)
Notification Format:
The notification format is the same as seen in the getAccountInfo RPC HTTP method
slot
The latest slot number
Request
1
const web3 = require("@solana/web3.js");
2
(async () => {
3
const solanaConnection = new web3.Connection("https://docs-demo.solana-mainnet.quiknode.pro/", {
4
wsEndpoint: "",
5
});
6
solanaConnection.onRootChange((rootInfo) =>
7
console.log("Updated slot info: ", rootInfo)
8
);
9
})();
10
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free