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

# Read private balances

> Read the private balance per token, list the notes behind it, and back them up

The private balance is the sum of the account's unspent notes in each pool. `createCloak` finds them
for you.

## Read the balance

```ts theme={null}
const balance = await cloak.balance();
console.log(balance); // { USDC: "12.5", USDT: "0", SOL: "0.0195", BRS: "0" }
```

Values are decimal strings in token units, so they render as they are and never lose precision. Each
call refreshes from the network by default. Pass `{ refresh: false }` to read what the object already
knows, for example right after a call that you know changed it.

```ts theme={null}
const cached = await cloak.balance({ refresh: false });
```

## List the notes

```ts theme={null}
const notes = await cloak.notes();
for (const n of notes) {
  console.log(n.token, n.amount, n.from, n.tx ?? "", n.exposed ? "(exposed)" : "");
}
```

| Field | Meaning |
| - | - |
| `token`, `amount` | The note's token and value |
| `from` | How it came in: `deposit`, `change`, `received`, `refund` or `created` |
| `tx` | The transaction that created it, when known |
| `exposed` | An older client left it readable by others. `createCloak` moves such notes into the account before spending them |

## Show balances in a UI

* Render `balance()` after each `shield`, `send` or `withdraw` resolves.
* Respect privacy on screen: offer a "hide balances" toggle; the private balance is the thing users
  came to protect.
* Poll sparingly. Each refresh reads from the network.

## Back up the notes

Notes created as change from the user's own spends cannot be rebuilt from the chain. Offer an
encrypted backup:

```ts theme={null}
const saved = await (await cloak.notes()).encryptToSave(secret); // one string, bound to this account
// later, on any device that opens the same account:
const { imported, skipped } = await cloak.importNotes(saved, secret);
```

`secret` is 32 random bytes, or a passphrase of 12 characters or more. `importNotes` only adds notes
that belong to this account and are unspent on chain. See [Notes and balances](https://docs.cloak.ag/concepts/notes-and-balances.md).

## With the low-level API

The low-level API keeps no state. Track notes yourself (`UtxoWallet`, or your own table), check them
against the chain with `verifyUtxos`, and restore them with `recoverNotesFromIndex` or
`scanTransactions` using the viewing key. See
[Solana wallet adapter](https://docs.cloak.ag/wallets/wallet-adapter.md#where-your-notes-live-between-sessions).

## Related

* [Transaction history](https://docs.cloak.ag/guides/transaction-history.md)
* [Notes and balances](https://docs.cloak.ag/concepts/notes-and-balances.md)


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