Overview
TheuseBalances hook fetches and manages user token balances aggregated across all supported chains. It automatically fetches balances when a predicted address is available and provides a manual refresh function.
Import
Signature
Parameters
string | null
required
The user’s predicted account address (smart contract wallet address). Balances are automatically fetched when this changes from
null to a valid address.Return Values
BalancesResponse | null
The aggregated balance data for all assets. Contains
balanceByAggregatedAsset array and totalBalance object.boolean
Indicates if balance data is currently being fetched.
string | null
Error message if balance fetching fails.
null when no errors.() => Promise<void>
Manually trigger a balance refresh. Useful after completing a swap or transfer.
Usage Examples
Basic Usage
Display Balance for Selected Asset
Refresh Balances After Swap
Balance List with Individual Chain Breakdown
Check Sufficient Balance
Types
BalancesResponse
BalanceByAssetDto
IndividualAssetBalance
TotalBalance
Notes
- Balances are automatically fetched when
predictedAddresschanges fromnullto a valid address - The hook uses the Balances API endpoint to fetch aggregated data
- Balance amounts are returned as strings (BigInt) in the smallest unit (wei)
- Use
formatTokenAmount()utility to convert balances to human-readable format - Individual asset balances show the breakdown across different chains
Related Hooks
- useAssets - Get available assets
- useQuotes - Fetch and execute swap quotes
- useEmbeddedWallet - Get embedded wallet
See Also
- Balances API - Backend API endpoint
- Token Utilities - Format and parse token amounts