slotSubscribe RPC Method
Parameters
This method does not accept any parameters
Returns
result
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
parent
The parent slot
root
The current root slot
slot
The newly set slot
Request
1const web3 = require("@solana/web3.js");2(async () => {3const solanaConnection = new web3.Connection("https://docs-demo.solana-mainnet.quiknode.pro/", {4wsEndpoint: "",5});6solanaConnection.onSlotChange((slotInfo) =>7console.log("Updated slot info: ", slotInfo)8);9})();10
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free