Skip to main content
The private balance is the sum of the account’s unspent notes in each pool. createCloak finds them for you.

Read the balance

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.

List the notes

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

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.