Documentation Index
Fetch the complete documentation index at: https://www.dynamic.xyz/docs/llms.txt
Use this file to discover all available pages before exploring further.
Summary
Fetches the private (shielded) token balances held by the primary wallet, for chains that distinguish a public balance from a private one. Today the only such chain in the SDK is Aleo; on every other chain the hook returns an empty list withsupportsPrivateBalances: false, so application code can call it unconditionally alongside useTokenBalances.
The return shape mirrors useTokenBalances with an added supportsPrivateBalances discriminator, so the two hooks can be composed with minimal call-site changes.
On Aleo, private balances are derived from owned records (“UTXOs”) fetched through the wallet iframe. The view key never leaves the iframe.
Usage
Return value
| Property | Type | Description |
|---|---|---|
tokenBalances | TokenBalance[] | One entry per token aggregated across all owned private records on the active wallet’s network. Zero-balance entries are filtered out. Same shape as useTokenBalances, including rawBalanceString for precision-safe encoding. |
isLoading | boolean | true while the initial fetch (or a refetch()) is in flight. |
error | string | undefined | The message of the last error from the underlying fetch, if any. |
refetch | () => Promise<void> | Force-refresh both credits and stablecoin / ARC-21 balances in parallel. Useful after a transaction that changes shielded state. |
supportsPrivateBalances | boolean | true when the active wallet’s chain supports private balances and the connector exposes the methods needed to enumerate them. For Aleo this requires a WaaS connector with listOwnedRecords — external Aleo wallets typically don’t expose this and return false. |
Refreshing after a transaction
On Aleo the SDK applies an optimistic update to both the public and private balances the moment
shieldToken resolves, so the UI reacts immediately without waiting for the indexer to surface the new record. A subsequent refetch() reconciles with the server once the record is indexed.Composing with useTokenBalances
Application code can call both hooks unconditionally and let the chain support flags decide which sections to render:
See also
- Using Aleo wallets — the broader Aleo guide, including the underlying
listOwnedRecords,shieldToken, andproveTransactionprimitives. useTokenBalances— public token balances on chains where Dynamic supports them.- Token Balances reference — caching, rate limiting, and supported chains for public balances.