Skip to main content

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.

import { useTokenSupply } from "@thirdweb-dev/react";

const { data, isLoading, error } = useTokenSupply(contractAddress);

Usage

Provide your token contract as the argument.

import { useTokenSupply } from "@thirdweb-dev/react";

// Your token contract address
const contractAddress = "{{contract_address}}";

function App() {
const { data, isLoading, error } = useTokenSupply(contractAddress);
}

Return Value

Return Value

The hook returns an object containing the following data:

{
symbol: string;
value: BigNumber;
name: string;
decimals: number;
displayValue: string;
}