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
1const web3 = require("@solana/web3.js");2(async () => {3const solanaConnection = new web3.Connection("https://docs-demo.solana-mainnet.quiknode.pro/", {4wsEndpoint: "",5});6solanaConnection.onRootChange((rootInfo) =>7console.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