blockSubscribe – Solana

The blockSubscribe JSON-RPC method allows clients to subscribe to Solana block notifications. This method triggers a notification whenever a new block is confirmed or finalized.

The blockSubscribe RPC Solana method provides real-time block notifications based on specified filters. Developers can track all transactions or only those related to a specific account or program.

Supported Networks

  • Mainnet

Parameters

Required Parameters

  • filter (string | object): Defines filter criteria for the notifications:

    • string: all – Receive notifications for all blocks.

    • object: A JSON object containing:

      • mentionsAccountOrProgram: A base-58 encoded string of an account or program.

Optional Parameters

  • object (optional): Configuration object containing:

    • commitment (string): Commitment level for block finality.

      • Default: finalized

    • encoding (string): Transaction encoding format.

      • Default: json

      • Supported: json, jsonParsed, base58, base64

    • transactionDetails (string): Level of transaction detail.

      • Default: full

      • Supported: full, accounts, signatures, none

    • maxSupportedTransactionVersion (number): The maximum transaction version to return.

    • showRewards (bool): Include block rewards.

      • Default: true

Result

The response returns a subscription ID.

Result Format

  • integer: The subscription ID.

Request Examples

API Endpoints

JSON-RPC Request – Subscribe to All Blocks

JSON-RPC Request – Subscribe to Specific Account/Program

Response

A successful request returns the subscription ID.

Example Response

In this response:

  • result: The subscription ID.

Error Handling

Common blockSubscribe error scenarios:

  • Invalid filter: Incorrect filter string or JSON object.

  • Unsupported encoding: Invalid encoding type.

  • Network issues: Problems with the Solana JSON-RPC API endpoints.

Example Error Response

Use Cases

The Solana blockSubscribe method is essential for:

  • Real-time block monitoring;

  • dApps requiring live transaction data;

  • Blockchain explorers tracking new blocks;

  • Performance analytics.

Code blockSubscribe Example – Web3 Integration

Integration with Web3

Integrating Web3 blockSubscribe into Solana's Core API allows developers to:

  • Receive block notifications for all blocks or specific accounts/programs.

  • Enhance real-time monitoring in blockchain applications.

Utilize transaction details for data analytics and performance insights.

Last updated

Was this helpful?