Account Filters

Subscribe to account updates with fine-grained filtering.

SubscribeRequestFilterAccounts

account
array of strings
Account Pubkeys to monitor. Matches any pubkey in the array (logical OR).
owner
array of strings
Account owner Pubkeys to monitor. Matches any owner in the array (logical OR).
filters
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)
nonempty_txn_signature
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:
message SubscribeRequestFilterAccountsFilterMemcmp {
  uint64 offset = 1;
  oneof data {
    bytes bytes = 2;
    string base58 = 3;
    string base64 = 4;
  }
}

Lamports

Filter accounts by lamport balance:
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

account
SubscribeUpdateAccountInfo
slot
uint64
Slot in which the update occurred.
is_startup
bool
Whether this is an initial snapshot during startup.

Account Examples

Subscribe to a Specific Account

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

Subscribe to All Token Accounts by Owner

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:
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:
const request = {
  accounts: {
    richAccounts: {
      owner: ["11111111111111111111111111111111"],
      filters: [
        { lamports: { gt: 1000000000 } },
      ],
    },
  },
  slots: {},
  transactions: {},
  transactionsStatus: {},
  blocks: {},
  blocksMeta: {},
  entry: {},
  accountsDataSlice: [],
  commitment: CommitmentLevel.CONFIRMED,
};