library / How to use Solana / Token-2022 / HS0090
Metadata update authority check
One TypeScript file reads Token-2022 mints, walks their extensions and prints the metadata pointer authority, the pointer target, the update authority and a verdict. Give it a mint, or let it pick mints from the newest transactions.
Where the metadata sits
A Token-2022 mint can keep its name, symbol and uri inside the mint account itself. The account starts with the 82-byte base mint, is padded to 165 bytes, carries one account type byte (1 for a mint), and then holds a list of extensions. Each extension is a type number, a length and a value, the first two as 16-bit little-endian integers. The metadata is the TokenMetadata extension, type 19. The extension that tells readers where to look is MetadataPointer, type 18.
In-mint metadata needs the pointer first. The pointer is set when the mint is created and names the mint itself as the account holding the metadata. A pointer can also name a different account, and then the mint carries a pointer and no metadata entry of its own. Wallets and explorers follow the pointer, so it decides where a reader looks, and the entry it lands on decides what the reader finds.
The two authorities
Each of the two extensions has its own key. The pointer holds an authority and a target address, 32 bytes each. The metadata entry starts with an update authority, followed by the mint address, the name, the symbol, the uri and a list of extra key and value pairs.
- The pointer authority can change the pointer's target. Whoever holds it can send every reader to a different account.
- The update authority can rewrite the name, symbol and uri, add or remove extra fields, and hand its role to another address.
- Both fields are optional addresses stored in 32 bytes, and 32 zero bytes mean none. Zeros cannot sign, so a field holding them has no editor.
Neither key implies the other. One wallet often holds both, but a mint can have a locked entry and a live pointer, or the reverse. The mint is immutable when the pointer names the mint and both fields hold zeros: nobody can edit the entry and nobody can redirect readers away from it.
The instructions that clear each
The update authority is cleared with the update-authority instruction of the token metadata interface, which sets a new authority. Passing none as the new value writes the 32 zero bytes. The current update authority signs it.
The pointer authority is cleared with the token program's set-authority instruction, using the authority type for the metadata pointer and a new authority of none. The current pointer authority signs it. The pointer's own update instruction only changes the target address, so it leaves the authority where it was.
Finish every edit first, because both changes are final. Correct the uri, aim the pointer where it should stay, and only then clear the two fields. This file signs and sends nothing: it reads a mint and reports what is left to clear.
Running the check
Install @solana/kit at 8.6.0, export CARBIUM_KEY and run the file with Node 24. Pass one or more mint addresses and it reads exactly those. With no argument it asks for the newest signatures of the Token-2022 program, fetches those transactions, collects every account key they touch and keeps the ones that turn out to be mints with a pointer or a metadata entry.
// HS0090 · Metadata update authority check// https://carbium.sh/library/howsolana/metadata-update-authority-check// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { address, createDefaultRpcTransport, createSolanaRpcFromTransport, getAddressDecoder, type Address } 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 = address("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");const decoder = getAddressDecoder();// An optional address is 32 bytes; all zeros means none.const who = (b: Uint8Array) => (b.every((x) => x === 0) ? "none" : decoder.decode(b));type Info = { ptrAuth?: string; ptrTarget?: string; updAuth?: string };// Mint layout: 165 bytes, account type at 165, then type/length/value entries.function walk(data: Uint8Array): Info | null { if (data.length <= 166 || data[165] !== 1) return null; const view = new DataView(data.buffer, data.byteOffset, data.byteLength); const info: Info = {}; for (let o = 166; o + 4 <= data.length; ) { const type = view.getUint16(o, true); const len = view.getUint16(o + 2, true); const v = data.subarray(o + 4, o + 4 + len); if (type === 18) { info.ptrAuth = who(v.subarray(0, 32)); info.ptrTarget = who(v.subarray(32, 64)); } if (type === 19) info.updAuth = who(v.subarray(0, 32)); o += 4 + len; } return info;}function verdict(mint: string, i: Info): string { if (i.ptrTarget === "none") return "pointer names no account"; if (i.ptrTarget !== undefined && i.ptrTarget !== mint) return `metadata lives at ${i.ptrTarget}`; if (i.ptrTarget === mint && i.updAuth === undefined) return "pointer names the mint, no metadata entry yet"; const open: string[] = []; if (i.updAuth !== undefined && i.updAuth !== "none") open.push(`update authority ${i.updAuth}`); if (i.ptrAuth !== undefined && i.ptrAuth !== "none") open.push(`pointer authority ${i.ptrAuth}`); if (i.ptrTarget === undefined && i.updAuth === undefined) return "no metadata extensions"; return open.length ? `can still change: ${open.join(", ")}` : "immutable";}async function discover(): Promise<Address[]> { const sigs = await rpc.getSignaturesForAddress(TOKEN_2022, { limit: 8, commitment: "confirmed" }).send(); const txs = await Promise.allSettled( sigs.filter((s) => !s.err).map((s) => rpc.getTransaction(s.signature, { encoding: "jsonParsed", maxSupportedTransactionVersion: 1, commitment: "confirmed" }).send(), ), ); const keys = new Set<Address>(); for (const t of txs) { if (t.status === "rejected") { console.error(`getTransaction failed: ${t.reason}`); continue; } const msg = t.value?.transaction.message as unknown as { accountKeys: { pubkey: Address }[] } | undefined; for (const k of msg?.accountKeys ?? []) keys.add(k.pubkey); } return [...keys].slice(0, 100);}const explicit = process.argv.slice(2);const mints = explicit.length ? explicit.map((a) => address(a)) : await discover();let shown = 0;for (let i = 0; i < mints.length; i += 100) { const chunk = mints.slice(i, i + 100); try { const { value } = await rpc.getMultipleAccounts(chunk, { encoding: "base64", commitment: "confirmed" }).send(); value.forEach((acc, j) => { const info = acc && acc.owner === TOKEN_2022 ? walk(Buffer.from(acc.data[0], "base64")) : null; const hasMeta = info && (info.ptrTarget !== undefined || info.updAuth !== undefined); if (!info || (!explicit.length && !hasMeta)) { if (explicit.length) console.log(`${chunk[j]}: not a Token-2022 mint with extensions`); return; } shown++; console.log(`${chunk[j]}\n pointer authority: ${info.ptrAuth ?? "-"}\n pointer target: ${info.ptrTarget ?? "-"}\n update authority: ${info.updAuth ?? "-"}\n verdict: ${verdict(chunk[j]!, info)}`); }); } catch (e) { console.error(`getMultipleAccounts failed for ${chunk.length} accounts: ${e}`); }}if (!shown && !explicit.length) console.log("No Token-2022 mint with metadata in the newest transactions; pass a mint address.");
run: node main.ts [mint-address ...]
The transaction fetch passes maxSupportedTransactionVersion: 1, because the newest transactions on mainnet can be version 1 and the node answers -32015 for them otherwise. Each fetch is settled on its own, so one failure is printed and the rest still count. The account read asks for base64 and at most 100 pubkeys a call. Every call uses confirmed commitment. The file walks the extension list by hand: type, length, value, next entry.
On Carbium an account read costs 10 cells per pubkey, which makes 1000 cells for 100 pubkeys and 1001 when the body passes 4 KiB. getSignaturesForAddress and each getTransaction cost 50 cells. A discovery run with 8 signatures therefore spends about 450 cells on the history part and one account read for the rest. The address signatures and the transaction lookups are separate rate classes, and each part sits inside its own class's 1,024-cell burst.
Reading the verdict
| Verdict | What it means |
|---|---|
| immutable | The pointer names the mint, and both the pointer authority and the update authority are none. |
| can still change: update authority A | The entry can be rewritten by A, and A can pass the role on. |
| can still change: pointer authority B | B can aim the pointer at another account, even if the entry itself is locked. |
| metadata lives at X | The pointer names X, so the mint's own entry is not the one readers follow. Check X. |
| pointer names the mint, no metadata entry yet | The pointer points at the mint, but no TokenMetadata entry exists. The mint authority can still add one. |
| pointer names no account | The pointer exists but holds zeros as its target, so nothing is set yet. |
| no metadata extensions | The mint has neither a pointer nor an in-mint entry. |
The printed lines show the raw fields as well, with none where the bytes are zero, so you can see which half of a mixed result is still open.
Where it ends
A pointer aimed at another account moves the question there. The file reports the target and stops. Whatever account sits at that address has its own owner and its own rules, and the mint's zero fields say nothing about it.
Metaplex metadata is a separate system. It lives in its own account derived from the mint and carries an is_mutable flag next to its update authority, so a mint can be locked in one place and open in the other. A Token-2022 mint that uses Metaplex metadata usually has no metadata pointer, or has one aimed at the Metaplex account, which the file reports as metadata lives at X.
Mint authority and freeze authority are separate again. The first decides who can create more supply, the second who can freeze token accounts, and neither one edits a name. An immutable entry also says nothing about the uri's target. The JSON file behind it sits on a web server or a storage network, and its owner can change what the file says while the chain stays frozen.
Discovery only samples. It looks at the newest signatures, and it keeps at most 100 account keys from them, so a quiet run can print nothing. The result is a read at confirmed commitment, taken at one moment. For a claim you plan to rely on, rerun it against the mint address by hand.
When it goes wrong
| what goes wrong | what to do |
|---|---|
| getTransaction answers -32015 during discovery. | The call left out maxSupportedTransactionVersion, or set it to 0. Set it to 1 so version 1 transactions are served. |
| HTTP 429 with a retry-after hint on the discovery fetches. | Wait for the seconds in the header and rerun, or lower the signature limit in the file. Each getTransaction costs 50 cells, so a short list stays inside the burst. |
| A mint you know has metadata prints not a Token-2022 mint with extensions. | The mint belongs to the classic token program or has no extensions. Call getAccountInfo on it and read the owner field. Metaplex metadata is not read by this file. |
| A getTransaction result is null for a signature the list returned. | The file skips it and reads the others. Older signatures can come from the address index past what the node still holds, so work from the newest ones. |
| A getMultipleAccounts call fails with more than 100 pubkeys below the Pro plan. | The 1024-cell burst caps a call at 100 pubkeys there. The file already sends 100 at most per call, so keep that when you change it. |
| The update authority is an address you cannot match to a person. | It may be a program derived address controlled by a program. Read that program's rules for who can make it sign. |
Questions
Does clearing the update authority also stop the pointer from being redirected?
No. The pointer has its own authority, set by its own instruction. Clear both to get the immutable verdict.
Can a cleared authority be set again later?
No. Zeros mean none, and the instruction that changes an authority needs the current authority to sign. Nobody can sign for none.
Does an immutable mint freeze the image and description?
Only the on-chain fields. The uri is stored on chain, but the file it points to is hosted elsewhere and its owner can change it.
Does the check need a wallet or signature?
No. It reads accounts and prints the decoded fields. The Carbium key only identifies your account to the RPC.
Why read base64 and decode by hand?
The raw bytes show exactly what the program stores, 32 zero bytes included, and the 20 lines that walk them are all the decoding the check needs.