Account Filters

Account Filters

Subscribe to account updates with fine-grained filtering.

SubscribeRequestFilterAccounts

array of strings

Account Pubkeys to monitor. Matches any pubkey in the array (logical OR).

array of strings

Account owner Pubkeys to monitor. Matches any owner in the array (logical OR).

array of SubscribeRequestFilterAccountsFilter

Additional filters (logical AND between filters):

  • memcmp - match bytes at a specific offset
  • datasize - match exact data size
  • token_account_state - filter for valid token account state
  • lamports - filter by lamport balance (eq, ne, lt, gt)
boolean

Only include account updates that have a non-empty transaction signature.

If all fields are empty, all accounts are broadcast. Otherwise, fields work as logical AND, and values within arrays as logical OR.

Filter Types

Memcmp

Match bytes at a specific offset in account data:

protobuf
message SubscribeRequestFilterAccountsFilterMemcmp {
  uint64 offset = 1;
  oneof data {
    bytes bytes = 2;
    string base58 = 3;
    string base64 = 4;
  }
}

Lamports

Filter accounts by lamport balance:

protobuf
message SubscribeRequestFilterAccountsFilterLamports {
  oneof cmp {
    uint64 eq = 1;  // equal to
    uint64 ne = 2;  // not equal to
    uint64 lt = 3;  // less than
    uint64 gt = 4;  // greater than
  }
}

Account Update Message

accountSubscribeUpdateAccountInfo
properties
pubkeybytes
Account public key.
lamportsuint64
Account balance in lamports.
ownerbytes
Program owner of the account.
executablebool
Whether the account contains a program.
rent_epochuint64
Next rent-due epoch.
databytes
Account data.
write_versionuint64
Write version for ordering.
txn_signaturebytes
Transaction signature that caused the update (optional).
slotuint64
Slot in which the update occurred.
is_startupbool
Whether this is an initial snapshot during startup.

Account Examples

Subscribe to a Specific Account

typescript
const request = {
  accounts: {
    myAccount: {
      account: ["vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg"],
    },
  },
  slots: {},
  transactions: {},
  transactionsStatus: {},
  blocks: {},
  blocksMeta: {},
  entry: {},
  accountsDataSlice: [],
  commitment: CommitmentLevel.CONFIRMED,
};

Subscribe to All Token Accounts by Owner

typescript
const request = {
  accounts: {
    tokenAccounts: {
      owner: ["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"],
      filters: [{ datasize: 165 }],
    },
  },
  slots: {},
  transactions: {},
  transactionsStatus: {},
  blocks: {},
  blocksMeta: {},
  entry: {},
  accountsDataSlice: [],
  commitment: CommitmentLevel.CONFIRMED,
};

Subscribe with Data Slicing

Receive only the first 32 bytes of account data to reduce bandwidth:

typescript
const request = {
  accounts: {
    myAccount: {
      account: ["vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg"],
    },
  },
  accountsDataSlice: [{ offset: 0, length: 32 }],
  slots: {},
  transactions: {},
  transactionsStatus: {},
  blocks: {},
  blocksMeta: {},
  entry: {},
  commitment: CommitmentLevel.CONFIRMED,
};

Filter by Lamport Balance

Monitor accounts with a balance greater than 1 SOL:

typescript
const request = {
  accounts: {
    richAccounts: {
      owner: ["11111111111111111111111111111111"],
      filters: [
        { lamports: { gt: 1000000000 } },
      ],
    },
  },
  slots: {},
  transactions: {},
  transactionsStatus: {},
  blocks: {},
  blocksMeta: {},
  entry: {},
  accountsDataSlice: [],
  commitment: CommitmentLevel.CONFIRMED,
};