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
| Parameter | Type | Required | Description |
|---|---|---|---|
address | PublicKey | null | undefined | No | The mint address to fetch. Query disabled when null or undefined. |
Return Value
| Property | Type | Description |
|---|---|---|
data | MintInfo | undefined | Parsed mint info from @solana/spl-token |
isLoading | boolean | True on the first fetch |
isError | boolean | True if the fetch failed |
refetch | () => void | Manually trigger a refetch |
MintInfo fields
| Field | Type | Description |
|---|---|---|
mintAuthority | PublicKey | null | The authority allowed to mint tokens |
supply | bigint | Total token supply (in raw units) |
decimals | number | Number of decimal places |
isInitialized | boolean | Whether the mint has been initialised |
freezeAuthority | PublicKey | null | The authority allowed to freeze accounts |