Hook for fetching the decimals of an ERC20 token.
Tokens usually opt for a value of 18 , imitating the relationship between Ether and Wei. Therefore, 18 is the default value returned by this function, unless your ERC20 contract explicitly overrides it.
18
import { useTokenDecimals, useContract } from "@thirdweb-dev/react"; function App() { const { contract } = useContract(contractAddress, "token"); const { data, isLoading, error } = useTokenDecimals(contract);}
function useTokenDecimals( contract: RequiredParam<TokenContract>,): UseQueryResult<number, unknown>;
Instance of a TokenContract
TokenContract
let contract: RequiredParam<TokenContract>;
let returnType: UseQueryResult<number, unknown>;
The hook's data property, once loaded, contains the number that represents the number of decimals of the ERC20 token.
data
number