# gRPC Account Filters

> Subscribe to Solana account updates with fine-grained filtering via Yellowstone gRPC.

Canonical: https://nolimitnodes.com/docs/api-reference/grpc/accounts

## 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.

> Note: 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

### `account`, SubscribeUpdateAccountInfo

### properties

Account public key.

    ### `lamports`, uint64

Account balance in lamports.

    ### `owner`, bytes

Program owner of the account.

    ### `executable`, bool

Whether the account contains a program.

    ### `rent_epoch`, uint64

Next rent-due epoch.

    ### `data`, bytes

Account data.

    ### `write_version`, uint64

Write version for ordering.

    ### `txn_signature`, bytes

Transaction signature that caused the update (optional).

### `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

```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,
};
```
