blockSubscribe
Subscribe to receive notification anytime a new block is confirmed or finalized.
Parameters
filter
(string | object, required)
filter
(string | object, required)Description: Filter criteria for the logs to receive results based on account type.
String Options:
all
: Include all transactions in the block.
Object Options:
A JSON object with the following field:
mentionsAccountOrProgram
(string
): Return only transactions that mention the provided public key (as a base-58 encoded string). If no mentions occur in a given block, no notification will be sent.
object
(optional)
object
(optional)Description: Configuration object containing the following fields:
commitment
(string, optional): Default:finalized
. Note:processed
is not supported.encoding
(string, optional): Default:json
. Specifies the encoding format for each returned transaction. Values:json
jsonParsed
base58
base64
Details:
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): Default:full
. Specifies the level of transaction detail to return. Values:full
accounts
signatures
none
Details:
If
accounts
is requested, transaction details only include signatures and an annotated list of accounts in each transaction.Transaction metadata is limited to:
fee
,err
,pre_balances
,post_balances
,pre_token_balances
, andpost_token_balances
.
maxSupportedTransactionVersion
(number, optional): Specifies the maximum transaction version to return in responses.Details:
If the requested block contains a transaction with a higher version, an error will be returned.
If omitted, only legacy transactions will be returned, and a block containing any versioned transaction will prompt an error.
showRewards
(bool, optional): Whether to populate therewards
array. Default behavior includes rewards if this parameter is not provided.
Result
Returns an integer
which serves as the subscription ID. This ID is required to unsubscribe.
Code Samples
Request Example 1 (Subscribe to all transactions in a block):
Request Example 2 (Filter by account and include optional configuration):
Response Example:
Notification Format
The notification is an object with the following fields:
slot
(u64
): The corresponding slot.err
(object | null
): Error if an issue occurs while publishing the notification; otherwisenull
.block
(object | null
): A block object as seen in thegetBlock
RPC HTTP method.
Example Notification
Last updated