Exports
Functions
getBalance(chainId, tokenAddress, walletAddress, cache?)
Get token balance for a specific wallet address.
Returns:
Balance
Throws:
InvalidAddressErrorif the wallet address is invalidBalanceFetchErrorif the API fails and no cache available
getBalances(walletAddress, chainIds, tokenAddresses?, cache?)
Get token balances across multiple chains in parallel.
Returns:
BalancesResponse
Example:
getChainBalances(walletAddress, chainId, cache?)
Get all supported token balances for a specific chain.
Returns: Array of
BalanceWithMetadata with extended information.
Example:
getBalanceWithMetadata(chainId, tokenAddress, walletAddress, cache?)
Get balance with additional metadata like USD value and price.BalanceWithMetadata
Example:
validateBalance(quote, walletAddress, cache?)
Validate that a user has sufficient balance to execute a quote.
Returns:
BalanceValidation
BalanceWarning Types:
Example:
checkBalance(chainId, tokenAddress, walletAddress, amount, cache?)
Quick check if a user has sufficient balance for a specific amount.
Returns:
BalanceCheckResult
Example:
Error Types
BalanceFetchError
Thrown when balance fetching fails.InvalidAddressError
Thrown when an invalid wallet address is provided.BalanceCache Class
TheBalanceCache class manages caching for balance data with a 30-second TTL.
