AptosAptos Network's breakthrough technology and seamless user experience are now available on QuickNode.
Start building today!The API credit value for this method is 1 . To learn more about API credits and each method's value, visit the API Credits page.
Parameters:
Returns:
integer - Subscription id (needed to unsubscribe)
Notification Format:
parent - The parent slot
root - The current root slot
slot - The newly set slot
Code Examples:
wscat -c wss://sample-endpoint-name.network.quiknode.pro/token-goes-here/ \ # wait for connection {"id":1,"jsonrpc":"2.0","method": "slotSubscribe" }
import solana import asyncio from asyncstdlib import enumerate from solana.rpc.websocket_api import connect async def main(): async with connect("wss://sample-endpoint-name.network.quiknode.pro/token-goes-here/") as websocket: await websocket.slot_subscribe() first_resp = await websocket.recv() subscription_id = first_resp.result async for idx, msg in enumerate(websocket): print(msg) asyncio.run(main())
const web3 = require("@solana/web3.js"); (async () => { const solanaConnection = new web3.Connection("http://sample-endpoint-name.network.quiknode.pro/token-goes-here/", { wsEndpoint: "wss://sample-endpoint-name.network.quiknode.pro/token-goes-here/", }); solanaConnection.onSlotChange((slotInfo) => console.log("Updated slot info: ", slotInfo) ); })();