How to Get a Token Mint

In order to get the current supply, authority, or decimals a token has, you will need to get the account info for the token mint.

import { Address, createSolanaRpc } from "@solana/kit";
import { fetchMint } from "@solana-program/token-2022";
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const address = "2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo" as Address;
const mint = await fetchMint(rpc, address);
console.log(mint);
Console
Click to execute the code.
Gill
import { address, createSolanaClient } from "gill";
import { fetchMint } from "gill/programs";
const { rpc } = createSolanaClient({
urlOrMoniker: "mainnet"
});
const mintAddress = address("2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo");
const mint = await fetchMint(rpc, mintAddress);
console.log(mint);

Is this page helpful?