useTokenSupply

Hook for fetching the total supply of an ERC20 token.

This takes into account the increase and decrease in supply when tokens are minted and burned.

Example

import { useTokenSupply } from "@thirdweb-dev/react";
function App() {
const { contract } = useContract(contractAddress);
const { data, isLoading, error } = useTokenSupply(contract);
}
function useTokenSupply(
contract: RequiredParam<TokenContract>,
): UseQueryResult<
{
decimals: number;
displayValue: string;
name: string;
symbol: string;
value: BigNumber;
},
unknown
>;

Parameters

Instance of a TokenContract

Type

let contract: RequiredParam<TokenContract>;

Returns

let returnType: UseQueryResult<
{
decimals: number;
displayValue: string;
name: string;
symbol: string;
value: BigNumber;
},
unknown
>;

Hook's data object includes the total supply of the token in the value property as a BigNumber object.