blockSubscribe
Last updated:
blockSubscribe pushes entire blocks over the WebSocket as the cluster
produces them, sparing you the poll-getBlocks-then-fetch-each-getBlock
loop. Each blockNotification carries the slot and a block object in the
same shape getBlock returns — blockhash, parent linkage, timestamp,
rewards, and the transaction list at the detail level you configure.
The first parameter is a filter: the string "all" streams every block,
while {"mentionsAccountOrProgram": "<pubkey>"} narrows the stream to blocks
containing at least one transaction that references the given account or
program — and in that case the notification's transaction list includes only
the matching transactions, not the whole block's. The config object then
controls payload weight: transactionDetails (full, accounts,
signatures, or none), encoding (json, jsonParsed, base58,
base64), showRewards, and maxSupportedTransactionVersion — set the
latter to 0 or versioned transactions in the block will make decoding fail.
commitment may be confirmed (default) or finalized; processed is
not supported for block subscriptions.
Use it when you genuinely need block-granular data live: feeding a real-time
indexer or analytics pipeline, computing per-block metrics (fees, compute
units, transaction counts), or tailing all activity of one program with
block-level ordering guarantees. If you only care about individual account
changes or log lines, accountSubscribe/logsSubscribe are far lighter.
Caveats worth planning around. In stock Solana this method is marked
unstable and only works on nodes started with the block-subscription flag
enabled — Triport routes /ws/sol block subscriptions to capable nodes, but
portability of your code to other RPC setups is not guaranteed. Full-detail
notifications are large (hundreds of KB, easily multiple MB per block), so
budget bandwidth and parsing time, and prefer transactionDetails: "signatures" or a mentions filter when you can. Skipped slots produce no
notification. The stream is session-scoped: after a reconnect, resubscribe
and backfill missed slots with getBlocks + getBlock. Stop with
blockUnsubscribe.
Parameters
This method takes no parameters.
Returns
| Field | Type |
|---|---|
| result | object |
Examples
curl https://triport.io/sol \
-X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer <api-key>' \
-d '{"id":1,"method":"blockSubscribe","params":[],"jsonrpc":"2.0"}'const res = await fetch("https://triport.io/sol", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
body: JSON.stringify({
"id": 1,
"method": "blockSubscribe",
"params": [],
"jsonrpc": "2.0"
}),
});
const data = await res.json();import requests
resp = requests.post(
"https://triport.io/sol",
headers={"Authorization": "Bearer <api-key>"},
json={"id":1,"method":"blockSubscribe","params":[],"jsonrpc":"2.0"},
)
print(resp.json())Usage
- Transport: WebSocket.
- Networks: mainnet, devnet, testnet.
- Credit cost: 1 per call.
FAQ
- What does blockSubscribe do?
- Subscribes to new blocks and streams each full block — optionally filtered to blocks mentioning a given account or program — as it is confirmed or finalized.
- How many credits does blockSubscribe cost?
- blockSubscribe costs 1 credit(s) per call on Triport by default.
- Is blockSubscribe available over WebSocket?
- Yes, blockSubscribe supports WebSocket.