Solana 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
commitmentparameter, 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?