Hooks
useMint

useMint

Fetch mint info for an SPL token mint address.

Import

import { useMint } from '@wankmi/wankmi'

Usage

import { useMint } from '@wankmi/wankmi'
import { PublicKey } from '@solana/web3.js'
 
const USDC_MINT = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
 
function USDCInfo() {
  const { data: mint, isLoading } = useMint({ address: USDC_MINT })
 
  if (isLoading) return <p>Loading...</p>
 
  return (
    <div>
      <p>Decimals: {mint?.decimals}</p>
      <p>Supply: {mint?.supply.toString()}</p>
    </div>
  )
}

Parameters

ParameterTypeRequiredDescription
addressPublicKey | null | undefinedNoThe mint address to fetch. Query disabled when null or undefined.

Return Value

PropertyTypeDescription
dataMintInfo | undefinedParsed mint info from @solana/spl-token
isLoadingbooleanTrue on the first fetch
isErrorbooleanTrue if the fetch failed
refetch() => voidManually trigger a refetch

MintInfo fields

FieldTypeDescription
mintAuthorityPublicKey | nullThe authority allowed to mint tokens
supplybigintTotal token supply (in raw units)
decimalsnumberNumber of decimal places
isInitializedbooleanWhether the mint has been initialised
freezeAuthorityPublicKey | nullThe authority allowed to freeze accounts