Websocket Methods
Subscribe to Real-Time Solana Data via WebSocket
After connecting to the RPC PubSub websocket at ws://<ADDRESS>/
:
Submit subscription requests to the websocket using the methods below
Multiple subscriptions may be active at once
Many subscriptions take the optional
commitment
parameter, defining how finalized a change should be to trigger a notification. For subscriptions, if commitment is unspecified, the default value isfinalized
.
Subscription Methods
These methods allow clients to subscribe to real-time updates about on-chain events through Solana’s WebSocket-based PubSub system. They're essential for building reactive applications like explorers, dashboards, bots, and monitoring tools.
accountSubscribe – Subscribes to updates on a specific account’s data. Useful for tracking balance changes or state updates in real time.
accountUnsubscribe – Cancels an active account subscription to stop receiving updates.
blockSubscribe – Subscribes to notifications whenever a new block is produced. Ideal for syncing block data or triggering logic based on finalized blocks.
blockUnsubscribe – Unsubscribes from block updates.
logsSubscribe – Subscribes to program log outputs (e.g., emitted via
msg!()
in Solana programs). Helpful for debugging, tracking program activity, or triggering off-chain events.logsUnsubscribe – Stops receiving program log updates.
programSubscribe – Subscribes to changes in all accounts owned by a specific program. Useful for monitoring a protocol’s account activity across the network.
programUnsubscribe – Unsubscribes from a program update stream.
signatureSubscribe – Subscribes to status updates for a given transaction signature. Used to monitor whether a specific transaction gets confirmed or fails.
signatureUnsubscribe – Stops tracking a specific transaction signature.
slotSubscribe – Subscribes to notifications whenever a new slot is processed. Useful for applications that need to stay in sync with the network clock.
slotUnsubscribe – Ends the slot subscription.
These real-time methods are vital for building event-driven dApps that respond to Solana state changes as they happen.
Last updated
Was this helpful?