blockSubscribe
Subscribe to receive a notification anytime a new block is Confirmed or Finalized.
This method will use 20 Compute Units.
Parameters
filtersstring. The filter criteria for the logs to receive results by account type. Currently it supports the following params:allstring. Includes all transactions in a block.objectobject. An object with the following field:mentionsAccountOrProgramstring Only retrieve transactions that reference the specified public key as a base-58 encoded string. If a block contains no such references, no notifications will be generated.
objectoptional. Configuration object containing the following fields:commitmentstring. The level of commitment required for the query. The options include:finalizedstring. The node will query the most recent block confirmed by the supermajority of the cluster as having reached maximum lockout, meaning the cluster has recognized this block as finalized.confirmedstring. The node will query the most recent block that has been voted on by the supermajority of the cluster.processedstring. The node will query its most recent block. Note that the block may not be complete.
transactionDetailsstring. The level of transaction detail to return, either 'full', 'signatures', or 'none'.showRewardsboolean. Indicated whether to populate the 'rewards' array.encodingstring. The encoding format for account data. It can be one of base58 (slow), base64, base64+zstd or jsonParsed.
Returns
result integer The subscription id.
blockNotification object. The notification object with the following fields:
slotinteger. The corresponding slot.errobject. Error if something went wrong publishing the notification otherwise null.blockobject. A block object as seen in the getBlock RPC HTTP method.
// Result
{
"jsonrpc": "2.0",
"id": "1",
"method": "blockSubscribe",
"params": [
{
"mentionsAccountOrProgram": "LieKvPRE8XeX3Y2xVNHjKlpAScD12lYySBVQ4HqoJ5op"
},
{
"commitment": "confirmed",
"encoding": "base64",
"showRewards": true,
"transactionDetails": "full"
}
]
}wscat -c wss://mainnet.solana.validationcloud.io/v1/<YOUR_API_KEY_HERE>
# wait for connection
{"id":1,"jsonrpc":"2.0","method":"blockSubscribe","params":["all"]}
wscat -c wss://devnet.solana.validationcloud.io/v1/<YOUR_API_KEY_HERE>
# wait for connection
{"id":1,"jsonrpc":"2.0","method":"accountSubscribe","params":["E645TckHQnDcavVv92Etc6xSWQaq8zzPtPRGBheviRAk",{"encoding": "jsonParsed", "commitment": "finalized"}]}
Last updated
Was this helpful?