Subscribing to Accounts

Subscribe requests related to streaming real-time account updates

To receive account updates we use the accounts filter of the Subscribe request. The account filter has the following structure.

{
  "slots": {},
  "accounts": {
      "accountLabel": {
        "account": string[], //account updates for these accounts 
        "owner": string[], //account updates for account with these owners
	"filters": {
	  "memcmp": {bytes and offset}  | undefined;
	  "datasize": string | undefined;
          "tokenAccountState": boolean | undefined;
        } 
  },
  "transactions": {},
  "blocks": {},
  "blocksMeta": {},
  "accountsDataSlice": [],
  "commitment": CommitmentLevel.CONFIRMED //commitment level, can be finalized or processed as well
}

The "key" at the start of all filters, (e.g. accountLabel, txnLabel) is a client-assigned label and can be set to any user-defined names.

Similar to the transactions filter, the first field under the accounts filter is the accountLabel, a user-defined label that helps you identify updates, especially when working with multiple filters. The account field specifies an array of account addresses for streaming account updates. The owner field streams updates for accounts owned by the specified addresses. Additionally, you can refine the data further by adding filters based on memcmp values, such as bytes and dataSize.

Last updated

Was this helpful?