Skip to main content

What is accountSubscribe?

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 WSS 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 (default), base64, base64+zstd, jsonParsed
  • commitment: defines the commitment level for the transaction. Supported values: finalized (default), confirmed, processed

Account Subscribe Example

In this example, we are subscribing to account changes for the account SysvarC1ock11111111111111111111111111111111. We will see an update whenever a change occurs to the account data or the lamports for this account. This happens at a frequent interval for this specific account as the slot and unixTimestamp are both a part of the returned account data.
Helius’s filtered accountSubscribe lives on the same unified wss://mainnet.helius-rpc.com and wss://devnet.helius-rpc.com endpoints as the rest of the WebSocket subscription methods.

Example Notification