Balance Management
This guide covers querying and displaying token balances using the Privacy Boost React SDK.Basic Usage
useBalances Return Value
| Property | Type | Description |
|---|---|---|
balances | FormattedBalance[] | All token balances with formatted strings |
loading | boolean | Whether balances are loading |
lastSynced | number | null | Timestamp of last sync |
getBalance | (tokenAddress) => FormattedBalance | Get balance for a specific token |
getShieldedBalance | (tokenAddress) => bigint | Get raw shielded balance |
getWalletBalance | (tokenAddress) => bigint | Get raw wallet balance |
totalShielded | bigint | Total shielded balance across all tokens |
tokenCount | number | Number of tokens with balances |
Balance Types
Syncing Balances
Complete Example
Best Practices
1. Use Formatted Values for Display
TheformattedShielded and formattedWallet strings are already human-readable. Use them directly instead of manually formatting.