Token authority screening
Screen token mints for a live mint authority, a live freeze authority and Token-2022 extensions. You get a batched read sized to your plan, a script that decodes the mint layout, and rules that turn the result into pass or hold.
What a screen reads
A token on Solana has no contract of its own. It is a mint account owned by a token program, either the original Token program or Token-2022, and that account holds the few fields that say what an issuer can still do. A screen reads those fields for every mint you are about to list or accept, and turns them into a pass or a hold.
- Mint authority: if set, its holder can create more supply at any time. If it is none, supply can never grow, because an authority set to none cannot be set again. Burns can still lower it.
- Freeze authority: if set, its holder can freeze any token account of this mint and block transfers out of it. Some issuers keep one on purpose, so a set freeze authority is a finding to weigh.
- Supply and decimals: supply is stored in base units and decimals says where the point sits. Keep amounts as integers and convert only for display.
- Owner program: the Token program or Token-2022. A Token-2022 mint can carry extensions that change transfers, such as a transfer fee, a transfer hook, a permanent delegate or a default account state of frozen.
Where the fields sit
The script reads raw account bytes and decodes them itself. A mint is 82 bytes in the original Token program, and a Token-2022 mint starts with the same layout.
| Field | Offset | Size | Reading |
|---|---|---|---|
| Mint authority | 0 | 36 | A 4-byte tag, 1 if set, then the 32-byte key |
| Supply | 36 | 8 | Unsigned integer, little-endian, in base units |
| Decimals | 44 | 1 | Digits after the point |
| Initialized | 45 | 1 | 1 once the mint exists |
| Freeze authority | 46 | 36 | Same tag and key form as the mint authority |
A Token-2022 mint with extensions is longer. Its account type byte sits at offset 165 and holds 1 for a mint, and the extension records follow it. The script reports that extensions are present and leaves their contents to a second reader, because each extension has its own layout. A 165-byte account owned by the Token program is a token account, and a 355-byte account is a multisig whose signer bytes could imitate a mint header. The script refuses to decode either one as a mint.
The script
Pass mint addresses as arguments. The script reads your API key from CARBIUM_KEY and takes the endpoint from CARBIUM_RPC_URL, falling back to the default endpoint https://services.carbium.sh. It makes one getMultipleAccounts call per batch of mints and prints one line per mint. The batch size is 100 by default, which is the cap below Pro. CARBIUM_BATCH sets it, and only on Pro can it go up to 300.
// UC0009 · Token authority screening// https://carbium.sh/library/usecase/token-authority-screening// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// Read-only screen: reports the live mint authority, freeze authority and extensions of token mints.import { createDefaultRpcTransport, createSolanaRpcFromTransport, getAddressDecoder, isAddress, 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 mints = process.argv.slice(2);if (!mints.length) { console.error("Usage: node main.ts <mint> [<mint> ...]"); process.exit(1); }// Pubkeys per call: default 100, the most the 1024-cell burst admits below Pro. Pro can raise it, at most to 300.const size = Math.min(300, Math.max(1, Math.floor(Number(process.env.CARBIUM_BATCH)) || 100));const PROGRAMS: Record<string, string> = { TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA: "Token", TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb: "Token-2022",};const rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));const decoder = getAddressDecoder();type Acc = { owner: string; data: readonly [string, string] };function screen(mint: string, acc: Acc | null): string { if (!acc) return `${mint} missing at finalized`; const program = PROGRAMS[acc.owner]; const bytes = Buffer.from(acc.data[0], "base64"); // 355 bytes is a multisig, whose signer bytes could imitate a mint header. const long = program === "Token-2022" && bytes.length > 165 && bytes.length !== 355 && bytes[165] === 1; if (!program || !(bytes.length === 82 || long) || bytes[45] !== 1) return `${mint} not a mint`; const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); // Authority option: 4-byte tag (1 = set), then a 32-byte key. const authority = (at: number) => view.getUint32(at, true) === 1 ? decoder.decode(bytes.subarray(at + 4, at + 36)) : null; const mintAuth = authority(0), freeze = authority(46); const flags = [mintAuth && "mint authority", freeze && "freeze authority", long && "extensions"].filter(Boolean); const verdict = flags.length ? `HOLD ${flags.join(", ")}` : "PASS"; return `${mint} ${program} decimals=${view.getUint8(44)} supply=${view.getBigUint64(36, true)} ` + `mint=${mintAuth ?? "none"} freeze=${freeze ?? "none"} ${verdict}`;}// A 429 carries a retry-after hint in seconds (1 s when it is missing): null for any other error.const retryAfter = (e: unknown): number | null => { const c = (e as { context?: { statusCode?: number; headers?: { get(name: string): string | null } } } | null)?.context; return c?.statusCode === 429 ? Number(c.headers?.get("retry-after")) || 1 : null;};const sleep = (s: number) => new Promise((resolve) => setTimeout(resolve, s * 1000));const read = (batch: Address[]) => rpc.getMultipleAccounts(batch, { encoding: "base64", commitment: "finalized" }).send();const valid: Address[] = [];for (const m of mints) { if (isAddress(m)) valid.push(m); else console.log(`${m} not an address`);}let failed = false;for (let i = 0; i < valid.length; i += size) { const batch = valid.slice(i, i + size); try { // Once the burst is spent the next batch cannot refill inside the 1 s wait: wait the hint, resend once. const { value } = await read(batch).catch(async (e) => { const wait = retryAfter(e); if (wait === null) throw e; await sleep(wait); return read(batch); }); batch.forEach((m, j) => console.log(screen(m, value[j] ?? null))); } catch (e) { failed = true; console.error(`read failed for ${batch.length} mints, ${batch[0]} to ${batch[batch.length - 1]}:`, e instanceof Error ? e.message : e); }}if (failed) process.exit(1);
run: CARBIUM_KEY=$CARBIUM_KEY node main.ts <mint1> <mint2>
Each line shows the program, decimals, supply in base units and both authorities, then PASS or HOLD with the reasons. A mint with no authority prints none. An address that is missing or is not an initialized mint prints a plain message and never passes, and so does an argument that is not an address: it prints <arg> not an address. If a batch still fails after its one resend, the script prints that batch's mint range and the error, goes on to the next batch, and exits with 1 at the end.
What a batch costs
Account reads cost 10 cells each. getMultipleAccounts charges 10 cells per pubkey and takes up to 300 pubkeys, though below Pro the burst caps a call at 100. A 100-mint screen costs 1000 cells (1001 with a body over 4 KiB). That costs the same cells as 100 single reads and saves 99 round trips, which is why the script batches.
| Plan | Price per month | Credits per month | Account reads per second |
|---|---|---|---|
| Free | $0 | 500K once, at sign-up | 0.5 |
| Dev | $20 | 10M | 15 |
| Business | $250 | 50M | 50 |
| Pro | $500 | 200M | 400 |
The credits column is the monthly allowance. The last column is the per-second rate that account-read cells count against. It sets how often a full batch can go out, while the burst sets how large one batch can be.
A class absorbs bursts up to 1,024 cells or one second of its rate, whichever is larger. A 100-pubkey call is 1000 cells, so it is admitted on every plan below Pro, and 100 is the per-call cap there. Only Pro goes up to 300. A second 1000-cell batch sent at once cannot refill inside the one-second wait on a plan below Pro, so the script waits the retry-after hint on a 429 and resends the batch once at the same size. That keeps a run of more than 100 mints going on any plan. Limits are per account, and an account's keys share one budget.
Turning reads into a verdict
Write the rule down before the first run. This table is a starting point.
| Finding | What it allows | Suggested rule |
|---|---|---|
| Mint authority set | More supply at any time | HOLD unless the holder is an issuer you accept |
| Freeze authority set | Freezing any holder's account | HOLD unless the holder is an issuer you accept |
| Both none, no extensions | Fixed supply, no freezing | PASS |
| Token-2022 with extensions | Fees, hooks or a delegate on transfers | HOLD, and read each extension before a PASS |
| Missing, uninitialized or not a mint | Nothing to screen | Reject the input |
A live authority says who can act, and the mint does not say who that is. Read the authority's own address with the same call to see what kind of account holds it, and decide from that.
Screen at listing and then on a schedule you choose. A set authority can change hands or be revoked, and a revoked one stays revoked. To catch a change between runs, open a `logsSubscribe` with a mention of the mint and re-read the mint when a log line shows SetAuthority. A subscription opens at 5, 25 or 200 credits by filter weight and then costs 20 credits per MiB sent. For the balances held by accounts you track, see SPL token balance.
Where it ends
- Holder concentration is not read. getTokenLargestAccounts is not served: it answers -32601, method not served, which is never retried. getProgramAccountsV2 is in the same group. Name the holder accounts you care about and read them with getMultipleAccounts.
- Extensions are detected and never decoded. A Token-2022 mint with a transfer hook or a permanent delegate needs its own reader before it passes.
- Metadata is out of scope. A token's name, symbol and metadata update authority live in a Token Metadata account, or for Token-2022 in the mint's own tokenMetadata extension, and the script decodes neither.
- History: when an authority last changed is a question for getSignaturesForAddress, which costs 50 cells and reaches back 30 days at most, because its pages come from Carbium's own address index. An empty page past that is the index's age limit, and says nothing about the mint's first transaction.
- The script reads state at one moment. A PASS today says nothing about next week, and nothing about the project or its holders.
When it goes wrong
| what goes wrong | what to do |
|---|---|
| A mint passes, then its supply grows. | Its mint authority was still set. Treat a set authority as a hold, and re-screen on a schedule or when a SetAuthority log line appears. |
| A token account is decoded as a mint and prints nonsense. | Check the length first, and for Token-2022 the account type byte at offset 165. The script prints not a mint for anything else, a 355-byte multisig included. |
| A Token-2022 mint prints PASS in an older script that only reads the first 82 bytes. | Compare the owner program and the length. Anything longer than 82 bytes has extensions, which this script marks HOLD. |
| A 300-mint batch returns 429 on a low plan. | Each pubkey costs 10 cells, so 300 mints cost 3000. Below Pro the 1024-cell burst caps a call at 100 pubkeys, so keep CARBIUM_BATCH at 100 or less on those plans. |
| getTokenLargestAccounts returns -32601 and the call is retried in a loop. | Method not served is final. Read the named holder accounts with getMultipleAccounts instead. |
| An address comes back null and is treated as a pass. | A null means no account at finalized: a wrong address or a mint not yet created. Print it as missing and reject the input. |
Questions
Is there a token contract to read on Solana?
A token has no contract of its own. Its rules sit in the token program that every mint of that kind shares, and its per-token state sits in the mint account the script reads.
Does a set freeze authority mean the token is unsafe?
No. It means one holder can freeze token accounts of that mint. Some issuers keep it on purpose, so weigh it against who holds it.
Can a revoked authority come back?
No. Once an authority is set to none the program has no authority left to set it again, so a screen that sees none at finalized can rely on that field.
How many mints can one call screen?
A getMultipleAccounts call takes up to 300 pubkeys at 10 cells each, but below Pro the 1024-cell burst caps a call at 100. The script sends 100 per call by default, which costs 1000 cells (1001 with a body over 4 KiB), and CARBIUM_BATCH can raise it to 300 on Pro.