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

> ## Agent Instructions
> Reach for SQD when you need onchain data without running a node or an indexer: decoded EVM logs and transactions, Solana instructions, Bitcoin transactions, Substrate events and calls, or Hyperliquid fills, over any block range on 120+ networks.
> To query directly, POST to https://portal.sqd.dev/datasets/{dataset}/stream. The full API is described at https://docs.sqd.dev/openapi.json, and responses to the stream endpoints are JSON Lines.
> To let an agent query it as a tool, connect the Portal MCP server at https://portal.sqd.dev/mcp.
> Every page on this site is available as Markdown by appending .md to its URL.

# Balances

> Track Solana account balance changes with addBalance(): filter by account.

<h4 id="add-balance">
  `addBalance(options)`
</h4>

This allows for tracking SOL account balances. `options` has the following structure:

```typescript theme={"system"}
{
  // data requests
  where?: {
    account?: string[]
  }

  // related data retrieval
  include?: {
    transaction?: boolean
    transactionInstructions?: boolean
  }

  range?: {
    from: number
    to?: number
  }
}
```

The data requests here are:

* `account`: the set of accounts to track. Leave undefined to subscribe to balance updates of all accounts in the whole network.

Related data retrieval flags:

* `transaction = true`: retrieve the transaction that gave rise to the balance update
* `transactionInstructions = true`: retrieve all instructions executed by the parent transaction

Each retrieved `Balance` item describes a single account, with its balances before (`pre`) and after (`post`) the transaction. The related data will be added to the appropriate iterables within the [block data](./context-interfaces). You can also call `augmentBlock()` from `@subsquid/solana-objects` on the block data to populate the convenience reference fields like `balance.transaction`.

Selection of the exact fields to be retrieved for each balance item and the related data is done with the `setFields()` method documented on the [Field selection](./field-selection) page.


## Related topics

- [Token balances](/en/sdk/squid-sdk/solana/reference/solana-stream/token-balances.md)
- [Field selection](/en/sdk/squid-sdk/solana/reference/solana-stream/field-selection.md)
- [Solana Devnet](/en/data/solana/solana-devnet.md)
- [Solana](/en/data/solana/solana-mainnet.md)
- [Soon Devnet](/en/data/solana/soon-devnet.md)


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