Parameters for tokens fetching
Optionalaccount?: `0x${string}`Account address for balance fetching (defaults to connected wallet)
OptionalchainId?: numberSpecific chain ID to filter tokens (defaults to all supported chains)
OptionalsortByBalance?: booleanWhether to sort tokens by balance. When false, source order is preserved even if balances are fetched.
OptionalwithBalance?: booleanWhether to fetch token balances
Token data and loading state
// Fetch all tokens with balances for connected wallet
const { tokens, tokensByChainId, isLoadingBalances } = useTokens();
// Fetch tokens for specific chain without balances
const { tokens } = useTokens({
chainId: 1,
withBalance: false
});
// Fetch balances for specific account
const { tokens } = useTokens({
account: '0x123...'
});
Custom hook for fetching and managing tokens data with price and balances.
Combines token list data with real-time price and balance information from LI.FI SDK. Features include:
On chains not covered by LI.FI (e.g. Sepolia), balance fetching falls back to a direct on-chain multicall. In this mode
priceUSDis absent from token extensions, so any UI that readsextensions.priceUSDshould treatundefinedas "N/A".