programSubscribe
Subscribe to a program to receive notifications when the lamports or data for an account owned by the given program changes
Parameters
string
(required)
string
(required)Pubkey of the program_id
, as a base-58 encoded string.
object
(optional)
object
(optional)Configuration object containing the following fields:
commitment
(string, optional): Specifies the desired level of commitment.filters
(array, optional): Filters to refine the results. The resultant account must meet all filter criteria to be included.encoding
(string, optional): Specifies the encoding format for Account data. Values:base58
base64
base64+zstd
jsonParsed
Details:
base58
encoding is slower.jsonParsed
attempts to use program-specific state parsers to return more human-readable and explicit account state data.If
jsonParsed
is requested but a parser cannot be found, the encoding falls back tobase64
(detectable when the data field is type string).
Result
Returns an <integer>
representing the subscription ID. This ID is required for unsubscribing.
Code Samples
Request Example 1 (Default configuration):
Request Example 2 (jsonParsed
encoding):
Request Example 3 (Filter by data size):
Response Example:
Notification Format
The notification format is a single program account object, structured similarly to the getProgramAccounts
RPC HTTP method.
Base58 Encoding Example:
Parsed-JSON Encoding Example:
Last updated