useBalance

Function: useBalance()

useBalance(UseBalanceParameters): undefined | { decimals: number; formatted: string; symbol: string; value: bigint; }

Computes and retrieves the token balance, decimals, and symbol information for a specified wallet address on a specific blockchain.

This function leverages blockchain read operations to fetch the balance of a token for a given wallet address along with associated token metadata such as decimals and symbol. It also formats the token balance for easier readability.

Parameters

UseBalanceParameters

UseBalanceParameters

The parameters for retrieving the balance.

Returns

undefined | { decimals: number; formatted: string; symbol: string; value: bigint; }

An object containing the balance information or undefined if data is not available:

  • value (BigInt): The raw token balance.

  • decimals (number): The number of decimal places for the token.

  • symbol (string): The symbol of the token.

  • formatted (string): The formatted balance value as a string with a fixed precision of 8.

Defined in

packages/wagmi/src/hook/useBalance.tsx:40

Last updated