Skip to content
LogoLogo

token.getTotalSupply

Gets the total supply of a TIP-20 token.

Usage

import { client } from './viem.config'
 
const totalSupply = await client.token.getTotalSupply({
  token: '0x20c0000000000000000000000000000000000000',
})
 
console.log('Total Supply:', totalSupply)
Total Supply: { amount: 1000000000000000n, decimals: 6, formatted: '1000000000' }

Return Type

type ReturnType = {
  /** Total supply in the token's base units. */
  amount: bigint
  /** Token decimals used to derive `formatted`. */
  decimals: number
  /** Total supply formatted with the token's `decimals`. */
  formatted: string
}

The total supply, both in base units (amount) and as a human-readable decimal string (formatted, derived from the token's decimals).

Parameters

token

  • Type: string

Token to operate on: a chain-declared token name (resolving its address and decimals), a TIP-20 token id, or a token address.

decimals (optional)

  • Type: number

Token decimals for converting base units to human-readable amounts. Inferred from the chain's tokens config, or fetched from the token contract when omitted.

blockNumber (optional)

  • Type: bigint

Block number to read the state from.

blockOverrides (optional)

  • Type: BlockOverrides

Block overrides to apply to the state.

blockTag (optional)

  • Type: BlockTag

Block tag to read the state from.

stateOverride (optional)

  • Type: StateOverride

State override to apply.