Skip to main content

useTokenBalance() function

This feature is currently in beta and may change based on feedback that we receive.

Use this to get the balance of your contract for a given address.

Example

const { contract } = useContract(<ContractAddress>);
const { data: balance, isLoading, error } = useTokenBalance(contract);

Signature:

export declare function useTokenBalance(
contract: RequiredParam<TokenContract>,
walletAddress: RequiredParam<WalletAddress>,
): import("@tanstack/react-query").UseQueryResult<
{
symbol: string;
value: import("ethers").BigNumber;
name: string;
decimals: number;
displayValue: string;
},
unknown
>;

Parameters

ParameterTypeDescription
contractRequiredParam<TokenContract>an instance of a TokenContract
walletAddressRequiredParam<WalletAddress>

Returns:

import("@tanstack/react-query").UseQueryResult<{ symbol: string; value: import("ethers").BigNumber; name: string; decimals: number; displayValue: string; }, unknown>

a response object that includes the balance of the address