githubEdit

accountSubscribe – Solana

The accountSubscribe JSON-RPC method enables clients to subscribe to updates about a specific Solana account.

circle-check

It provides a subscription ID that can be used to unsubscribe later. The notification format is similar to the getAccountInfo method's response.

Supported Networks

  • Mainnet

Parameters

Required Parameters

  • string (required): The account Pubkey as a base-58 encoded string.

Optional Parameters

  • object (optional): A configuration object containing:

    • commitment (string): Commitment level to observe.

    • encoding (string): The encoding format for the account data.

      • Supported: base58, base64, base64+zstd, jsonParsed.

Result

The response returns a subscription ID required to unsubscribe from the account notifications.

Result Format

  • number: The subscription ID.

Request Example

API Endpoints

JSON-RPC Request

Response

A successful request returns a subscription ID.

Example Response

In this response:

  • result: The subscription ID assigned to this account.

Notification Formats

Base58 Encoding

Parsed JSON Encoding

Error Handling

Common accountSubscribe error scenarios:

  • Invalid Pubkey: Incorrect account Pubkey.

  • Unsupported encoding: Invalid encoding format.

  • Network issues: Connectivity problems with Solana JSON-RPC API endpoints.

Example Error Response

Use Cases

The Solana accountSubscribe method is essential for:

  • Real-time account balance monitoring;

  • Tracking smart contract state changes;

  • Enabling event-driven dApp functionality;

Code accountSubscribe Example – Web3 Integration

Integration with Web3

By integrating Web3 accountSubscribe into Solana's Core API, developers can monitor account changes, optimize dApp performance, and enable responsive features. This method is vital for Web3 applications that depend on real-time data updates.

Last updated

Was this helpful?