Skip to main content

slotSubscribe RPC Method

(Subscription Websocket) Subscribe to receive notification anytime a slot is processed by the validator.

Updated on
Oct 4, 2023

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
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.onSlotChange((slotInfo) =>
7
console.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