> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solanatracker.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Stream Solana Account Updates with gRPC

> Subscribe to Solana account changes with Yellowstone gRPC. Filter by address, program owner, data size, or memcmp and request byte slices.

Subscribe to account writes when you need updated balances or program state. An `owner` filter means the program that owns an account, not the wallet that owns tokens inside it.

Save the [quickstart helper](https://docs.solanatracker.io/yellowstone-grpc/quickstart.md) as `stream.mts` in the same directory. These examples use the same environment variables and dependencies.

## Watch one account

```typescript accounts.mts theme={null}
import bs58 from "bs58";
import { subscribe } from "./stream.mts";

const address = process.env.ACCOUNT_ADDRESS;
if (!address) throw new Error("Set ACCOUNT_ADDRESS");

for await (const update of subscribe({
  accounts: { selected: { account: [address], owner: [], filters: [] } },
})) {
  const account = update.account?.account;
  if (!account) continue;
  console.log({
    address: bs58.encode(account.pubkey),
    owner: bs58.encode(account.owner),
    lamports: account.lamports,
    slot: update.account!.slot,
    writeVersion: account.writeVersion,
    dataBytes: account.data.length,
  });
}
```

```bash theme={null}
export ACCOUNT_ADDRESS="YOUR_ACCOUNT_ADDRESS"
npx tsx accounts.mts
```

## Filter program accounts

This request selects legacy SPL Token accounts for one mint and downloads only their amount field. Pass `request` to `subscribe(request)` in place of the previous account filter.

```typescript theme={null}
import { makeRequest } from "./stream.mts";

const tokenProgram = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
const mint = process.env.TOKEN_MINT;
if (!mint) throw new Error("Set TOKEN_MINT");

const request = makeRequest({
  accounts: {
    tokenAccounts: {
      account: [],
      owner: [tokenProgram],
      filters: [
        { datasize: "165" },
        { memcmp: { offset: "0", base58: mint } },
      ],
    },
  },
  accountsDataSlice: [{ offset: "64", length: "8" }],
});
```

The spelling is `datasize`, and offsets are strings in this client. Filters within one named account filter are combined; named filters can be used for separate selections.

## Decode sliced token amounts

Inside the account handler, decode the eight-byte slice as an unsigned little-endian integer:

```typescript theme={null}
// A slice of bytes 64–71 from a legacy SPL token account contains its amount.
const amount = Buffer.from(account.data).readBigUInt64LE(0);
console.log(amount.toString());
```

> [!NOTE]
>
> The 165-byte size and offsets above describe legacy SPL Token accounts. Token-2022 extensions can change account size. Do not apply this filter to every token program without checking its layout.

## Keep state after a disconnect

Store the account address, slot, and write version with each update. Refresh a REST/RPC snapshot after a gap before treating the local cache as current. A wallet-address subscription alone does not cover its separate token accounts.

## Related guides

> [card] [Transactions](https://docs.solanatracker.io/yellowstone-grpc/transaction-monitoring.md)

> [card] [Pump.fun accounts](https://docs.solanatracker.io/yellowstone-grpc/examples/pumpfun-accounts.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.