blockSubscribe RPC Method
Subscribe to receive notification anytime a new block is confirmed
or
finalized
.
This subscription is considered unstable and is only available if the
validator was started with the --rpc-pubsub-enable-block-subscription
flag.
The format of this subscription may change in the future.
Parameters
filter string | object
required
filter criteria for the logs to receive results by account type; currently supported:
string
all
- include all transactions in block
object
A JSON object with the following field:
mentionsAccountOrProgram: <string>
- return only transactions that mention the provided public key (as base-58 encoded string). If no mentions in a given block, then no notification will be sent.
object
optional
Configuration object containing the following fields:
commitment string
optional
finalized
processed
is not supported.
encoding string
optional
json
encoding format for each returned Transaction
Values: json
jsonParsed
base58
base64
jsonParsed
attempts to use program-specific instruction parsers to return more human-readable and explicit data in thetransaction.message.instructions
list.- If
jsonParsed
is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (accounts
,data
, andprogramIdIndex
fields).
transactionDetails string
optional
full
level of transaction detail to return
Values: full
accounts
signatures
none
- If
accounts
are requested, transaction details only include signatures and an annotated list of accounts in each transaction. - Transaction metadata is limited to only: fee, err, pre_balances, post_balances, pre_token_balances, and post_token_balances.
maxSupportedTransactionVersion number
optional
the max transaction version to return in responses.
- If the requested block contains a transaction with a higher version, an error will be returned.
- If this parameter is omitted, only legacy transactions will be returned, and a block containing any versioned transaction will prompt the error.
showRewards bool
optional
whether to populate the rewards
array. If parameter not provided, the
default includes rewards.
Result
integer
- subscription id (needed to unsubscribe)
Code sample
Response
Notification Format:
The notification will be an object with the following fields:
slot: <u64>
- The corresponding slot.err: <object|null>
- Error if something went wrong publishing the notification otherwise null.block: <object|null>
- A block object as seen in the getBlock RPC HTTP method.