Hook for getting a wallet's current balance of native or (optional) ERC20 token balance
import { useBalance } from "@thirdweb-dev/react"; function App() { const { data, isLoading } = useBalance();}
import { useBalance } from "@thirdweb-dev/react"; function App() { const { data, isLoading } = useBalance(tokenAddress);}
function useBalance( tokenAddress?: string,): UseQueryResult< | { decimals: number; displayValue: string; name: string; symbol: string; value: BigNumber; } | undefined, unknown>;
The address of the token contract, if not provided, it defaults to the native token
let tokenAddress: string;
let returnType: UseQueryResult< | { decimals: number; displayValue: string; name: string; symbol: string; value: BigNumber; } | undefined, unknown>;
The hook's data property contains the token's balance in the value property as a BigNumber object.
data
value
BigNumber