Skip to main content

useTokenDecimals() function

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

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

Example

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

Signature:

export declare function useTokenDecimals(
contract: RequiredParam<TokenContract>,
): import("@tanstack/react-query").UseQueryResult<number, unknown>;

Parameters

ParameterTypeDescription
contractRequiredParam<TokenContract>an instance of a TokenContract

Returns:

import("@tanstack/react-query").UseQueryResult<number, unknown>

a response object that includes the decimals of the ERC20 token