services
Get a key

library / How to use Solana / HS0013

Token-2022 metadata lookup

One TypeScript file takes a mint, reads its Token-2022 extensions, and says where its metadata lives: the pointer's target, the mint itself, or the Metaplex metadata account. It only reads, with no keypair and no signature.

By Carbium · Token-2022 · HS0013 · updated 2026-11-22

01

Where a mint's metadata can live

A mint account stores supply, decimals and a few authorities. It stores no name, symbol or image. Those sit in a metadata record, and three places can hold one, so the first job is to find which place a given mint uses.

  • A Metaplex Token Metadata account: a separate account at an address derived from the mint, owned by the program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s.
  • A tokenMetadata extension inside the mint: the mint itself carries name, symbol and uri. Token-2022 owns the mint, so no separate metadata program exists.
  • Any other account that a metadataPointer extension names: whatever program owns that account is the metadata program.

The Metadata Pointer is the mint's own statement of where to look. When the metadataPointer extension is set, read the address it holds and check which program owns the account there. When the extension is missing, the mint makes no statement, and you fall back to convention.

  1. Read the metadataPointer extension. If it holds an address other than the mint, the owner of the account at that address is the metadata program.
  2. Look for a tokenMetadata extension inside the mint. This step only matters when a pointer exists but is unset or names the mint, because Token-2022 needs the pointer on the mint before it writes the in-mint record. If the record is there, Token-2022 is the program and there is nothing else to call.
  3. Derive the Metaplex metadata address from the mint and read it. If an account exists there, the Metaplex program owns it.
  4. If all three come up empty, the mint has no on-chain metadata in any place the file checks.

A mint owned by the classic Token program has no extensions, so it goes straight to the third check.

$The owner of the mint answers a different question. It names the token program, Token or Token-2022, and says nothing about who holds the metadata. The file prints both so the two never get mixed up.
02

The code

Add @solana/kit 8.6.0 to the project, set CARBIUM_KEY in the environment and start the file on Node 24, which strips TypeScript types by itself. Pass a mint as the first argument. With none, it uses PYUSD, a public Token-2022 mint.

main.ts
// HS0013 · Token-2022 metadata lookup// https://carbium.sh/library/howsolana/token-2022-metadata-lookup// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { setTimeout as sleep } from "node:timers/promises";import {  address,  createDefaultRpcTransport,  createSolanaRpcFromTransport,  getAddressEncoder,  getProgramDerivedAddress,  getUtf8Encoder,  isSolanaError,  SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR,} from "@solana/kit";const key = process.env.CARBIUM_KEY;if (!key) {  console.error("Set CARBIUM_KEY to your Carbium API key.");  process.exit(1);}const url = process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh";const rpc = createSolanaRpcFromTransport(  createDefaultRpcTransport({ url, headers: { "x-api-key": key } }),);const TOKEN_2022: string = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";const METAPLEX = address("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");const PYUSD = "2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo";const mint = address(process.argv[2] ?? PYUSD);type Ext = { extension: string; state: Record<string, unknown> };type Parsed = { parsed?: { type?: string; info?: { extensions?: Ext[] } } };async function read(a: typeof mint) {  const call = () =>    rpc.getAccountInfo(a, { encoding: "jsonParsed", commitment: "confirmed" }).send();  try {    return (await call()).value;  } catch (e) {    if (!isSolanaError(e, SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR) || e.context.statusCode !== 429) throw e;    const seconds = Number(e.context.headers.get("retry-after")) || 1;    console.error(`429: waiting ${seconds}s, then one more try`);    await sleep(seconds * 1000);    return (await call()).value;  }}const acct = await read(mint);if (!acct) {  console.error(`No account at ${mint}.`);  process.exit(1);}const parsed = (acct.data as unknown as Parsed).parsed;if (parsed?.type !== "mint") {  console.error(`${mint} is not a mint (owner ${acct.owner}).`);  process.exit(1);}const exts = parsed.info?.extensions ?? [];const program = acct.owner === TOKEN_2022 ? "Token-2022" : "the classic Token program";console.log(`mint ${mint} is owned by ${program}, ${exts.length} extension(s)`);const pointer = exts.find((x) => x.extension === "metadataPointer")?.state.metadataAddress;const pointed = typeof pointer === "string" ? pointer : undefined;const inMint = exts.find((x) => x.extension === "tokenMetadata")?.state;if (pointed && pointed !== mint) {  const target = await read(address(pointed));  console.log(    target      ? `pointer -> ${pointed}, owned by ${target.owner}: that program holds the metadata`      : `pointer -> ${pointed}, but no account exists there`,  );} else if (inMint) {  console.log(`${pointed ? "pointer -> the mint itself" : "no pointer, tokenMetadata in the mint"}: Token-2022 holds the metadata`);  console.log(`name=${inMint.name} symbol=${inMint.symbol} uri=${inMint.uri}`);} else {  const enc = getAddressEncoder();  const [pda] = await getProgramDerivedAddress({    programAddress: METAPLEX,    seeds: [getUtf8Encoder().encode("metadata"), enc.encode(METAPLEX), enc.encode(mint)],  });  const found = await read(pda);  const why = pointed ? "pointer targets the mint but no tokenMetadata is there" : "no pointer";  console.log(    found      ? `${why}; Metaplex metadata account ${pda} is owned by ${found.owner}`      : `${why}, and no Metaplex metadata account at ${pda}: no on-chain metadata found`,  );}

run: node main.ts [mint-address]

The read requests jsonParsed encoding, which makes the node decode the Token-2022 extensions into extension and state pairs. Base64 would leave the extension layout for you to decode.

The Metaplex address is a program derived address built from three seeds: the text metadata, the Metaplex program id and the mint. Deriving it is local arithmetic. It makes no request and needs no key. Before anything else the file confirms the account is a mint, so a wallet or a token account passed by mistake stops with a clear line.

03

Reading the answer

Each run prints the mint's owner and the number of extensions, then one line for the metadata.

What printsWhat it meansMetadata program
pointer -> the mint itself, then name, symbol and uriThe pointer targets the mint and the mint holds the recordToken-2022
pointer -> an address, owned by a programThe pointer targets another accountThe program that owns that account
pointer -> an address, but no account exists thereThe pointer leads to a closed or never-created account, so no metadata program is foundNone found
no pointer, tokenMetadata in the mintPointer cleared to none after setup, tokenMetadata still in the mintToken-2022
pointer targets the mint but no tokenMetadata is there; ...The pointer names the mint, yet the mint holds no record, so the line goes on with the Metaplex resultWhatever the Metaplex check finds
no pointer; Metaplex metadata account ... owned by metaqbxx...The record sits at the derived Metaplex addressMetaplex Token Metadata
no pointer, and no Metaplex metadata account: no on-chain metadata foundNo on-chain metadata where the file looksNone found

The extension list for a Token-2022 mint with no extensions is empty, and that is a normal answer. It sends the file to the Metaplex check. A mint can also carry a metadataPointer extension whose address is unset. The file treats that like a missing pointer.

The order matters when a mint carries more than one record. A pointer is the issuer's explicit statement, so it comes first. The in-mint record comes next because it costs no extra read. The Metaplex address comes last because it is a convention that holds for any mint, and the file reads it only when the mint itself gave no answer.

04

On Carbium

Requests go to https://services.carbium.sh, authenticated with your API key. The file creates its rpc client once at the top and uses it for every read.

Each getAccountInfo call sits in the account-read class of the RPC rates, at 10 cells a call. The allowance per second is 0.5 on Free, 15 on Dev, 50 on Business and 400 on Pro. One run needs a single read for a mint that holds its own record, and two when the pointer names another address or the Metaplex account has to be checked. A class absorbs bursts of at least 1,024 cells, so the two 10-cell reads of one run pass at once on every plan.

For a long list of mints, call getMultipleAccounts, which accepts up to 300 pubkeys per call at 10 cells each. Compute the Metaplex addresses locally for the mints that carry no in-mint record, then fetch them in one more call. A loop of single reads is fine for a handful. The batch takes two requests per 300 mints, plus one more for pointer targets that name other accounts. Below Pro the burst caps a call at 100 pubkeys, so count per 100 there.

A -32601 answer means method not found: a misspelt method name, or a method Carbium does not serve. Retrying never helps. The file retries a 429 and nothing else, so a -32601 is thrown at once.

05

Where it ends

A missing pointer is no proof that metadata is missing. The file's last line, no metadata found, means that none of the three places it checks holds a record. It cannot see a record that another program keeps at an address of its own, because nothing on the mint links to it. Only the issuer's documentation can tell you that.

The file finds the program and the account, then stops. A Metaplex metadata account is a Borsh layout owned by a program the node does not parse, so the RPC returns it as base64 and the file prints only its owner. To get name, symbol and uri from it, decode the layout or use a Metaplex library. The in-mint record is already decoded by jsonParsed, which is why the file can print those three fields for it.

A pointer authority can change the address later, and a pointer can lead to an account that is closed or was never created. The file reports that case in one line. The answer is also as of the confirmed read. A mint created a moment ago can be missing from it, and a read at finalized is the one to use before you act on the result in a way you cannot undo.

06

When it goes wrong

what goes wrongwhat to do
No account at the address you passed.Check the spelling and that it is a mainnet mint. A mint created in the last moments can be missing from a confirmed read, so try again after a few seconds.
The file stops with a line saying the address is not a mint.You passed a wallet or a token account. Take the mint address from the token account's mint field, which getAccountInfo with jsonParsed returns for it, and run the file on that.
The extension list is empty for a Token-2022 mint.This is normal for a mint made without extensions. The file moves on to the Metaplex check by itself, so no change is needed.
The pointer names an address and the file says no account exists there.The pointer leads to an account that is closed or was never created. The mint has no usable record at that address, so ask the issuer for the right one.
HTTP 429 with a retry-after hint.Sleep for the seconds the header gives and call again, as the file does once. If the 429 comes back, space the reads out or move to a plan with a higher account-read allowance.
Error -32601 method not found.Correct the method name. A method Carbium does not serve answers -32601 every time, so a retry changes nothing.
07

Questions

Does a Token-2022 mint with no Metadata Pointer have a metadata program?

A mint with no metadataPointer extension cannot carry in-mint tokenMetadata, so its metadata program is Metaplex at the derived address, or there is none the chain links to. The file keeps the in-mint check for a pointer that was later cleared to none. It tells you which place answered.

Why not read the Metaplex address first for every mint?

A pointer or an in-mint record is the issuer's explicit choice, and both come back in the mint read the file already made. Following a pointer to another address costs one more read. The Metaplex address is the fallback for mints that made no such choice.

Do I need a private key for this?

No. The file reads accounts and derives an address locally. The Carbium key only identifies your account to the RPC.