Account Subscribe

Solana’s Websockets support a method that allows you to subscribe to an account and receive notifications via the WebSocket connection whenever there are changes to the lamports or data associated with a matching account public key. This method aligns directly with the Solana Websocket API specification.

Parameters

string: The account public key, sent in base58 format (required).

object: An optional object used to pass additional parameters.

  • encoding: Specifies the format for data returned in the AccountNotification. Supported values: base58, base64, base64+zstd, jsonParsed (default is base58).
  • commitment: Defines the commitment level for the transaction. Supported values: finalized, confirmed, processed (default is finalized).

Examples

Basic Account Subscribe Example