Solana exposes a PubSub WebSocket API alongside its standard HTTP JSON-RPC. Each subscription opens a long-lived stream that pushes notifications when on-chain state changes (account data, program-owned accounts, transaction logs, signature status, slots, blocks, votes, and roots).
Connect to the PubSub endpoint using your Alchemy WebSocket URL:
wss://solana-mainnet.g.alchemy.com/v2/<-- ALCHEMY APP API KEY -->Solana uses native *Subscribe / *Unsubscribe methods instead of eth_subscribe. Each *Subscribe call returns a numeric subscription id which you pass to the matching *Unsubscribe to cancel the stream.
Solana PubSub uses JSON-RPC 2.0 over a persistent WebSocket connection.
| Field | Type | Description |
|---|---|---|
jsonrpc | string | JSON-RPC version. Set this to "2.0". |
id | string | number | null | Client-supplied request identifier. The server echoes it in the subscribe response. |
method | string | PubSub method name, such as accountSubscribe or slotSubscribe. |
params | array | Ordered method parameters. Use an empty array when the method takes no parameters. |
Many subscription methods accept an optional commitment parameter. Subscriptions that accept commitment default to finalized when unspecified.
After a subscribe request succeeds, the server returns a numeric subscription id in the JSON-RPC response. Later notifications are pushed as JSON-RPC messages with a method-specific notification name and the active subscription id.
| Field | Type | Description |
|---|---|---|
jsonrpc | string | JSON-RPC version. |
method | string | Notification name, such as accountNotification or slotNotification. |
params.result | any | Method-specific notification payload. Many methods include a context object and a method-specific value. |
params.subscription | number | Subscription id returned by the corresponding *Subscribe method. |
| Method | Description |
|---|---|
accountSubscribe | Subscribe to notifications when one account's lamports or data change. |
programSubscribe | Subscribe to notifications for accounts owned by a program. |
| Method | Description |
|---|---|
logsSubscribe | Subscribe to transaction log messages that match a log filter. |
signatureSubscribe | Subscribe to status notifications for one transaction signature. |
| Method | Description |
|---|---|
rootSubscribe | Subscribe to notifications when the validator sets a new root slot. |
slotSubscribe | Subscribe to notifications when the validator processes a new slot. |
Solana WebSocket subscriptions on Alchemy are billed by bandwidth — pro-rated to the exact byte. See Compute Unit Costs for the per-byte CU rate and PAYG pricing.
Broad streams can produce very high bandwidth, especially programSubscribe without filters. To keep usage predictable:
- Prefer the most specific stream and scope with
mentions/mentionsAccountOrProgram/dataSize/memcmpfilters. - Keep payloads small (e.g.
encoding: "base64",transactionDetails: "signatures"). - Set usage limits and usage alerts before running high-volume streams in production.
Check the Chains page for details about product and chain support!
