library / Blockchain ideas / Token tools / BI0134
Metadata mutability check
A check that takes token mints and says which ones a creator can still rename or re-skin. It reads the metadata flag and the update authority, looks at where the picture's uri points, and returns one of four verdicts.
What a creator can still change
A token's name, symbol and picture are not stored in the mint. For a classic SPL token they live in a Token Metadata account at an address derived from the mint, and that account holds an is_mutable flag and an update authority. While the flag reads true, the holder of the update authority can rewrite the name, the symbol and the uri with one signed instruction. Selling the token on a DEX touches none of this: a sale moves balances between token accounts and leaves the metadata account where it was.
- is_mutable: true means the authority can still edit name, symbol and uri. False closes those three fields for good.
- The update authority: a single wallet, a multisig or a program, and that choice sets how much the flag should worry you.
- The uri: the picture is a file the uri points to. With the flag false, the file can still change when a server the creator controls hosts it.
The flag moves one way only. A creator can turn it from true to false and can never turn it back, so a false reading is final for that mint and a true reading can change tomorrow. A token may keep it true on purpose, to fix a typo or move a logo, so true is a fact about power and says nothing about intent.
Reading the metadata account
The account sits at the address derived from the seeds metadata, the Token Metadata program id (metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s) and the mint, under that program. It is Borsh. A key byte of 4 comes first, then 32 bytes of update authority, 32 bytes of mint, and three length-prefixed strings for name, symbol and uri. On chain the strings are padded with NUL characters to a fixed width, so the code trims them.
After the strings come a two-byte seller fee, an optional list of 34-byte creators and a one-byte sale flag. The next byte is is_mutable. The code walks to it by hand, which takes a dozen lines and needs no client library.
Where the picture lives
The uri in the account names a JSON file, and that file's image field names the picture. Neither lives on chain. A locked flag freezes the uri string and says nothing about the bytes behind it.
Three hosting patterns show up. An ipfs:// address, or a gateway path containing /ipfs/, derives from the file's hash, so the content cannot change without the address changing. An Arweave address points at permanent storage. A plain https address on the creator's own server is a file the creator can overwrite at will, on a token whose flag has been locked for months.
The code tells the first two from the third with a pattern match on the uri and never downloads the JSON.
The four verdicts
| Verdict | What the account says | What a buyer can count on |
|---|---|---|
| editable | is_mutable is true | The named update authority can change name, symbol and picture at any time |
| locked | is_mutable is false and the uri is content-addressed or on Arweave | Name, symbol and the metadata file are fixed; the picture is fixed too when the file's image field is content-addressed |
| locked name, movable picture | is_mutable is false and the uri is a plain host | Name and symbol are fixed; the creator can still replace the file at that address |
| no Token Metadata account | Nothing at the derived address | No answer from this check: the token may keep its name inside the mint, or the address is not a mint |
The update authority matters most on an editable token. A lone hot wallet means the person who launched the token can edit it from a phone, and a multisig means a change needs several signatures. The check prints the authority and stops there. Whether that address is a lone wallet or a multisig is a question for a lookup on the address.
The check in code
The script takes mint addresses as arguments, up to 100. It derives each metadata address, reads all of them in one getMultipleAccounts call, and prints the name, symbol, flag, authority, uri and verdict for each. An address with no Token Metadata account, or an account owned by another program, gets the no-account verdict.
// BI0134 · Metadata mutability check// https://carbium.sh/library/blockchainideas/metadata-mutability-check// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { address, createDefaultRpcTransport, createSolanaRpcFromTransport, getAddressDecoder, getAddressEncoder, getProgramDerivedAddress, getUtf8Encoder, type Address,} from "@solana/kit";const apiKey = process.env.CARBIUM_KEY;if (!apiKey) { 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": apiKey } }));const METADATA_PROGRAM = address("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");const PERMANENT_URI = /^(ipfs|ar):\/\/|\/ipfs\/|arweave\.net\//;async function metadataAddress(mint: Address): Promise<Address> { const enc = getAddressEncoder(); const [pda] = await getProgramDerivedAddress({ programAddress: METADATA_PROGRAM, seeds: [getUtf8Encoder().encode("metadata"), enc.encode(METADATA_PROGRAM), enc.encode(mint)], }); return pda;}// Borsh walk from the start of a Token Metadata account to its is_mutable byte.function parse(base64: string) { const d = Buffer.from(base64, "base64"); if (d[0] !== 4) return null; // key 4 is MetadataV1 let o = 65; // key byte, update authority, mint const text = (): string => { const n = d.readUInt32LE(o); const s = d.toString("utf8", o + 4, o + 4 + n).replace(/\0+$/, ""); // fixed-width, NUL padded o += 4 + n; return s; }; const [name, symbol, uri] = [text(), text(), text()]; o += 2; // seller fee basis points if (d[o++]) o += 4 + 34 * d.readUInt32LE(o); // optional creators: address, verified, share o += 1; // primary_sale_happened return { authority: getAddressDecoder().decode(d, 1), name, symbol, uri, mutable: d[o] === 1 };}function verdict(m: ReturnType<typeof parse>): string { if (!m) return "no Token Metadata account: nothing to check here"; if (m.mutable) return `editable: ${m.authority} can change name, symbol and picture at any time`; return PERMANENT_URI.test(m.uri) ? "locked: name, symbol and metadata file are fixed; the picture follows the file's image host" : "locked name and symbol; the picture file sits on a host that can swap it";}// The newest Token Metadata transactions touch mints; take up to 10 of them.async function sample(): Promise<Address[]> { const sigs = await rpc.getSignaturesForAddress(METADATA_PROGRAM, { limit: 12 }).send(); const txs = await Promise.allSettled(sigs.filter((s) => !s.err).map((s) => rpc.getTransaction(s.signature, { encoding: "json", maxSupportedTransactionVersion: 1 }).send())); const mints = new Set<Address>(); for (const t of txs) { if (t.status === "rejected") console.error("getTransaction failed:", t.reason?.message ?? t.reason); else for (const b of t.value?.meta?.postTokenBalances ?? []) mints.add(b.mint); } if (!mints.size) throw new Error("no mints in the newest transactions; pass mint addresses"); return Array.from(mints).slice(0, 10);}async function main() { const args = process.argv.slice(2); const mints = args.length ? args.slice(0, 100).map((a) => address(a)) : await sample(); // 100 is the most one call carries below Pro const { value } = await rpc.getMultipleAccounts(await Promise.all(mints.map(metadataAddress)), { encoding: "base64" }).send(); value.forEach((acc, i) => { const m = acc?.owner === METADATA_PROGRAM ? parse(acc.data[0]) : null; console.log(`\n${mints[i]}${m ? ` ${m.name} (${m.symbol})` : ""}`); if (m) console.log(` is_mutable ${m.mutable}\n authority ${m.authority}\n uri ${m.uri}`); console.log(` ${verdict(m)}`); });}main().catch((e) => { console.error(e instanceof Error ? e.message : e); process.exit(1);});
run: CARBIUM_KEY=<YOUR_KEY> node main.ts <mint> [<mint> ...]
Run with no arguments, it builds its own sample. It lists the newest 12 signatures of the Token Metadata program, fetches each transaction with maxSupportedTransactionVersion: 1, and gathers up to 10 mints from the token balances. A rejected call is printed and skipped. A getTransaction costs 50 cells and Free allows 0.24 of them a second, so on Free several of the 12 reads may end in a 429 while the survivors still supply the sample.
Using it before you list a token
A token page, a wallet's add-token screen or a swap UI's token list can call the check once per mint and show the verdict beside the name. Batching puts fifty tokens in one request. Token metadata change alerts pairs well: the alert reports a change, and this check tells you which tokens were able to make one.
Each pubkey in a `getMultipleAccounts` call costs 10 cells, the same as a single read per mint, so batching trims round trips and leaves the bill unchanged. One call holds at most 100 pubkeys below Pro, and Pro accepts up to 300. Budgets belong to the account, so every key on it draws from one pool. Account reads run at 0.5 req/s on Free, 15 on Dev, 50 on Business and 400 on Pro. A page that checks one token per view on Free hits a 429 fast, so keep the locked verdicts in a cache.
Where it ends
- A token that keeps its name inside the mint under Token-2022 has no Token Metadata account here and reads as no-account. Token-2022 metadata lookup covers that form, which needs a metadataPointer extension on the mint naming where the data lives.
- The picture verdict is a guess from the uri's shape. The code never downloads the JSON, so it never sees the image field: a content-addressed file can still name a picture on a plain https host the creator can swap, and a plain host that has served the same image for years still reads as movable.
- A locked flag freezes Token Metadata and nothing else. The mint can still gain supply while a mint authority exists, and a freeze authority can still freeze accounts. Those live on the mint account, which this script does not read.
- It shows today's state. To see who changed a name, read getSignaturesForAddress on the metadata address, which reaches back 30 days at most, then fetch each transaction. Pages reach below the validator's ledger floor, so getTransaction can answer null for an older signature; handle null.
- A lookalike name is a different problem. The check says nothing about whether a name copies another token's.
When it goes wrong
| what goes wrong | what to do |
|---|---|
| Every mint reads as no Token Metadata account. | Pass mint addresses; a wallet or token account address derives a metadata account that does not exist. A Token-2022 token with its name inside the mint reads the same way. |
| getTransaction answers -32015 in sample mode or in your own code. | Pass maxSupportedTransactionVersion: 1 with an encoding. Absent or 0, a v1 transaction or a block holding one answers -32015. |
| Calls answer 429. | Space reads to your plan's account-read rate, cache locked verdicts, and wait for the retry-after hint before trying again. Batching mints into one getMultipleAccounts call trims round trips but still costs 10 cells per pubkey. |
| Sample mode ends with an error that it found no mints. | Run it again so it reads newer transactions, or pass mints yourself. On Free some of the 12 transaction reads can come back as 429. |
| A token read as locked and its picture changed anyway. | The flag freezes the uri string only, and the JSON it names can point its image field at any host. Open the JSON and treat an image on a plain https host as movable. |
Questions
Does selling a token on a DEX change who can edit it?
No. A sale moves token balances and leaves the metadata account under its update authority until that authority signs a change.
Can a creator turn a locked token back to editable?
No. is_mutable goes from true to false and never back, so a false reading holds for the life of the mint.
How many tokens can one call check?
One getMultipleAccounts call carries up to 100 metadata addresses below Pro and up to 300 on Pro. Parse each result with the same function.
Do I need a Metaplex library for this?
Not for these fields. The walk to the flag is a few lines of offsets. A client library helps when you want fields further along the account.