---
id: HS0133
title: "Token name and symbol lookup"
url: https://carbium.sh/library/howsolana/token-name-and-symbol-lookup
collection: How to use Solana
category: SPL tokens
revision: 1
updated: 2026-11-23
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Token name and symbol lookup

One TypeScript file takes one or more mint addresses and prints each token's name, symbol and decimals. It reads the mint account and, for classic tokens, the Metaplex metadata account beside it. It only reads: no keypair, no transaction, no state change.

## What the calls read

A token's name, symbol and decimals are not stored in one place. Decimals sit on the mint account, which defines the token and holds its supply and authorities. The name and symbol sit somewhere else, depending on the token program that created the mint. Classic SPL mints keep them in a separate Metaplex metadata account. Token-2022 mints can keep them inside the mint itself, through the `tokenMetadata` extension. This file checks both places.

For a classic mint, the metadata account address is a program derived address built from three seeds: the bytes of the word `metadata`, the Metaplex Token Metadata program id and the mint. Deriving it is local arithmetic, so it costs no request. `getAccountInfo` then reads that account in base64, and the file decodes the fixed header by hand. The name and symbol are Borsh strings that follow a one-byte key and a 32-byte update authority and mint, so the file reads them from known offsets and adds no dependency beyond `@solana/kit`.

The mint read uses `jsonParsed` encoding. For a classic mint the node returns decimals, supply and the authorities as named fields. For a Token-2022 mint it also lists the extensions, and the `tokenMetadata` entry carries the name and symbol directly, so no second read is needed. Supply and authorities are covered in [token supply and authorities](https://carbium.sh/library/howsolana/token-mint-supply-and-authorities).

## The code

Install `@solana/kit` at 8.6.0, export `CARBIUM_KEY` and run the file with Node 24, which strips the TypeScript types on load. Pass one or more mint addresses after the file name. With no argument the file reads USDC.

`main.ts` (run: `node main.ts [mint-address ...]`)

```ts
// HS0133 · Token name and symbol lookup
// https://carbium.sh/library/howsolana/token-name-and-symbol-lookup
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import { Buffer } from "node:buffer";
import {
  address,
  createDefaultRpcTransport,
  createSolanaRpcFromTransport,
  getAddressEncoder,
  getProgramDerivedAddress,
} 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 METADATA_PROGRAM = address("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
const USDC = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
const mints = process.argv.slice(2);
if (mints.length === 0) mints.push(USDC);

type Parsed = { type: string; info: Record<string, unknown> };
type Extension = { extension: string; state?: Record<string, unknown> };
const enc = getAddressEncoder();
const text = new TextEncoder();

// Metaplex layout: key u8, update authority 32 bytes, mint 32 bytes, then Borsh strings name, symbol, uri.
function metaplexStrings(buf: Buffer): { name: string; symbol: string } {
  const read = (at: number) => {
    const len = buf.readUInt32LE(at);
    const value = buf
      .subarray(at + 4, at + 4 + len)
      .toString("utf8")
      .replace(/\0/g, "")
      .trim();
    return { value, next: at + 4 + len };
  };
  const name = read(65);
  const symbol = read(name.next);
  return { name: name.value, symbol: symbol.value };
}

async function lookup(mintText: string): Promise<string> {
  const mint = address(mintText);
  const { value } = await rpc
    .getAccountInfo(mint, { encoding: "jsonParsed", commitment: "confirmed" })
    .send();
  if (!value) return `${mintText}: no account on mainnet`;
  const parsed = (value.data as unknown as { parsed?: Parsed }).parsed;
  if (!parsed) return `${mintText}: not a token mint`;
  const decimals = parsed.info.decimals;

  const extensions = (parsed.info.extensions as Extension[] | undefined) ?? [];
  const inMint = extensions.find((e) => e.extension === "tokenMetadata")?.state;
  if (inMint) {
    return `${mintText}: name=${inMint.name} symbol=${inMint.symbol} decimals=${decimals} (Token-2022 metadata)`;
  }

  const [pda] = await getProgramDerivedAddress({
    programAddress: METADATA_PROGRAM,
    seeds: [text.encode("metadata"), enc.encode(METADATA_PROGRAM), enc.encode(mint)],
  });
  const meta = await rpc
    .getAccountInfo(pda, { encoding: "base64", commitment: "confirmed" })
    .send();
  if (!meta.value) {
    return `${mintText}: decimals=${decimals}, no Metaplex metadata account at ${pda}`;
  }
  const { name, symbol } = metaplexStrings(Buffer.from(meta.value.data[0], "base64"));
  return `${mintText}: name=${name} symbol=${symbol} decimals=${decimals} (metadata ${pda})`;
}

const results = await Promise.allSettled(mints.map((m) => lookup(m)));
results.forEach((r, i) => {
  if (r.status === "fulfilled") {
    console.log(r.value);
  } else {
    const reason = r.reason instanceof Error ? r.reason.message : String(r.reason);
    console.log(`${mints[i]}: failed: ${reason}`);
  }
});
```

The transport sends every call to `https://services.carbium.sh` with the key in the `x-api-key` header, and the client is created once and reused. Each mint runs in its own `lookup` call, and `Promise.allSettled` lets one bad address finish without stopping the others. The decode reads the name length as a little-endian `u32`, takes that many bytes and strips the zero padding Metaplex adds to fixed-width fields.

The mint read and the metadata read are two separate calls. A mint whose metadata changes between them can show a name from a later moment. For a display that is fine, and for anything that must match one moment exactly, read both at the same slot with `minContextSlot`. The file does not decode the URI field, which points to off-chain JSON that this file never fetches.

## Reading the answer

| Field | Source | Meaning |
|---|---|---|
| name | Metaplex account, or tokenMetadata extension | The label the update authority last wrote, such as USD Coin. |
| symbol | Metaplex account, or tokenMetadata extension | The short ticker, such as USDC. |
| decimals | Mint account | How many digits sit after the decimal point. USDC uses 6. |
| metadata | Derived offline | The Metaplex account address that was read, or a note that none exists. |

Decimals tell you how to scale a raw amount from `getTokenAccountBalance`. A raw USDC amount of `1234567` with 6 decimals is `1.234567`. Keep the raw amount as a string or a `BigInt` and scale it only for display.

> Name and symbol are text that the update authority wrote, not a check of the token. Identify the token by its mint address, and show the name beside that address.

## On Carbium

Each [account read](https://carbium.sh/docs/rpc) costs 10 cells, and `getAccountInfo` is one of them. Free allows 0.5 account reads per second, Dev 15, Business 50 and Pro 400. A classic mint takes two reads in this file, so on Free one mint takes about 4 seconds of sustained rate. Dev finishes the same two reads well inside a second.

To read a long list, derive every metadata address offline first, then pass the addresses to `getMultipleAccounts` with base64 encoding. The call costs 10 cells per pubkey, so a 100-pubkey call costs 1,000 cells. It takes up to 300 pubkeys on Pro, but the 1,024-cell burst caps a call at 100 pubkeys below Pro. A batch of up to 100 calls can go in one POST, which the same limits govern.

A call over its rate waits once and is served if its cells refill within 1 second. Past that, the [limits](https://carbium.sh/docs/limits) answer with HTTP 429 and a retry-after hint. The [errors](https://carbium.sh/docs/errors) page lists the other codes a read can return.

## Where it ends

A classic name and symbol belong to the update authority. That authority can change them unless the metadata is marked immutable, and this read does not check who set the fields or whether they can still change. Two mints can both print the symbol USDC. The mint address identifies the token, and the name is only a label beside it.

Many mints have no metadata account at all. The file then prints the decimals and says no Metaplex account exists, and it does not guess a name from another source. An empty name in the output means the same thing: the mint or its authority has not written one.

Token-2022 is the other gap. The in-mint `tokenMetadata` extension is present only when the mint also carries the `metadataPointer` extension that names the mint itself. Some Token-2022 mints point their metadata at a separate account. This file reads the mint's own extension and falls back to the Metaplex address, so it misses a metadata account that a pointer names elsewhere.

The file reads two or three accounts per mint and nothing from transaction history. It does not return a token's full metadata history, its creator or the other fields a marketplace shows.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| Name and symbol print as blank or as a missing metadata note, while decimals print normally. | The mint is live but has no metadata, or its authority left the fields empty. Identify the token by its mint address and treat the name as unset. |
| A mint argument fails before any request is sent. | Copy the mint address as base58 with no spaces. Each bad argument shows as its own failed line, and the other mints still print. |
| HTTP 429 with a retry-after hint. | Wait for the number of seconds in the header, then run the failed mint again. For a long list, batch the metadata addresses with `getMultipleAccounts`. |
| A metadata address decodes to unreadable text. | The file does not check the account owner. Confirm that the account's owner is the Metaplex Token Metadata program before you trust the name, because another account at that address would decode to noise. |
| Two tokens show the same symbol. | Compare mint addresses, never symbols. A symbol is a label the update authority wrote, and any token can print one. |

## Questions

### Can the mint account alone give me the token's name?

For a classic mint, no. The mint holds decimals, supply and authorities. The name and symbol live in the Metaplex account derived from the mint, which this file reads.

### Do I need a private key or a wallet to run this?

No. Every call is a read, and the Carbium key only identifies your account to the RPC. The file never signs or sends anything.

### Can I show the name to users as the token's identity?

Show it with the mint address beside it. The name comes from whoever last set the metadata, so the mint address is what identifies the token.

### How do I read a long list of mints without hitting the rate limit?

Derive every metadata address offline, then read them in batches with `getMultipleAccounts`. A 100-pubkey call costs 1,000 cells, which fits the burst on every plan.

## Related

- [Token mint supply and authorities](https://carbium.sh/library/howsolana/token-mint-supply-and-authorities) (How to use Solana, HS0005)
- [Wallet token holdings](https://carbium.sh/library/usecase/wallet-token-holdings) (Use cases, UC0005)
- [carbium.sh/docs/rpc](https://carbium.sh/docs/rpc)
- [carbium.sh/docs/auth](https://carbium.sh/docs/auth)
- [carbium.sh/docs/limits](https://carbium.sh/docs/limits)
- [carbium.sh/docs/errors](https://carbium.sh/docs/errors)
- [carbium.sh/docs/endpoints](https://carbium.sh/docs/endpoints)
