services
Get a key

library / Use cases / UC0071

Token freeze event monitor

Watch which Solana token accounts an issuer freezes or thaws. You get a script that reads each stablecoin mint's freeze authority and searches that authority's newest transactions for FreezeAccount and ThawAccount, plus how to read its output.

By Carbium · Compliance, risk and monitoring · UC0071 · updated 2026-11-22

01

What a blacklist is on Solana

A Solana token has no contract of its own that you can add a blacklist function to. Its balances and rules live in a shared token program, either the original Token program or Token-2022, and each mint is one account that records what its issuer may still do. A blacklist in the usual sense is one of those powers: the freeze authority, a key that can block a single token account.

A program you write can hold its own deny list and refuse calls from listed wallets. That is program logic, and it only governs instructions that go through your program. A plain transfer goes to the token program, which has never seen your list. Token-2022 closes part of that gap with a transfer hook, a program the mint names that runs on every transfer and can reject it. Either way the code sits in a program, and a program is normally upgradeable, so a list written into it can change when its upgrade authority signs.

MechanismWhere the code sitsWhat it blocks
Freeze authorityToken program, set on the mintOne token account at a time, by an instruction the authority signs
Transfer hookA hook program, Token-2022 onlyAny transfer its code rejects
Deny list in your own programYour programOnly calls that pass through your program

Freezes are the part an issuer or compliance team can follow with ordinary reads, because they leave a mint field, an account state and a trail of transactions.

02

The freeze authority on a mint

A mint stores an optional freeze authority at byte offset 46: a 4-byte tag, then a 32-byte key when it is set. When the tag says none, nobody can freeze any account of that mint, and since a cleared authority cannot be set again, that stays true. When a key is there, its holder can freeze and thaw any token account of the mint with one instruction per account.

getAccountInfo with jsonParsed encoding returns the decoded mint, so the key arrives as freezeAuthority and you decode no bytes. The mint does not say what kind of account holds that key. It can be a single wallet, a multisig or a custody vault, and the answer decides what a freeze means in practice. Screening for the field itself is covered in Token authority screening. This monitor starts from a set authority and watches what it signs.

The authority can also move. A SetAuthority instruction hands it to a new key or clears it, so the script reads it again on every run.

03

The frozen state on a token account

A token account holds a state byte at offset 108: 0 for uninitialized, 1 for initialized, 2 for frozen. In jsonParsed output it reads as state. A frozen account cannot send or receive tokens of its mint, and its owner has no way to undo that, because only the freeze authority can thaw it.

Reading state on one account answers whether it is frozen now. It does not tell you when the freeze happened, which key asked for it, or whether the account was thawed and frozen again since. Those answers sit in the authority's transaction history.

A freeze lands on one token account. A wallet can own more than one token account for the same mint, so keep the token account address and its owner side by side in your records.

04

Finding freeze and thaw events

The script takes mint addresses as arguments and falls back to USDC, USDT and PYUSD. For each mint it reads the account with getAccountInfo, takes freezeAuthority and the token program that owns the mint, then asks getSignaturesForAddress for that authority's five newest signatures and fetches each successful one with getTransaction. A page that held only failed transactions costs no transaction read, so the script pages back with before and tries the next five. It stops at the first page that reads a transaction, returns a null, comes back short, or after six pages or 25 seconds. Reads leave commitment out, so @solana/kit fills in confirmed.

The transaction call passes maxSupportedTransactionVersion: 1. Mainnet carries v1 transactions, and without that setting getTransaction answers -32015 for one instead of returning it.

main.ts
// UC0071 · Token freeze event monitor// https://carbium.sh/library/usecase/token-freeze-event-monitor// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// Read-only: reads each mint's freeze authority, then searches that authority's newest transactions for FreezeAccount and ThawAccount.import { createDefaultRpcTransport, createSolanaRpcFromTransport, address, getBase58Encoder, type Signature } 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.length > 2 ? process.argv.slice(2) : [  "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC  "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", // USDT  "2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo", // PYUSD];const LOOK = 5; // signatures read per pageconst PAGES = 6; // most pages per authority; only a page of failed transactions pages onconst DEADLINE = Date.now() + 25_000; // stop paging after 25 secondsconst rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));const text = (e: unknown) => (e instanceof Error ? e.message : String(e));const b58 = getBase58Encoder();const NAMES: Record<number, string> = { 10: "FreezeAccount", 11: "ThawAccount" };type Parsed = { type?: string; info?: { freezeAuthority?: string | null; extensions?: { extension: string; state?: { accountState?: string } }[] } };type Ix = { programIdIndex: number; accounts: number[]; data: string };type Tx = {  transaction: { message: { accountKeys: string[]; instructions: Ix[] } };  meta: { loadedAddresses?: { writable: string[]; readonly: string[] }; innerInstructions?: { instructions: Ix[] }[] } | null;};async function readMint(mint: string) {  const { value } = await rpc.getAccountInfo(address(mint), { encoding: "jsonParsed" }).send();  const parsed = (value?.data as unknown as { parsed?: Parsed } | undefined)?.parsed;  if (!value || parsed?.type !== "mint") throw new Error("not a parsed mint account");  const state = parsed.info?.extensions?.find((x) => x.extension === "defaultAccountState")?.state?.accountState;  return { freeze: parsed.info?.freezeAuthority ?? null, program: String(value.owner), defaultState: state ?? "none" };}// Freeze is data byte 10, thaw is 11; the instruction's accounts are [token account, mint, authority].function events(tx: Tx, program: string, mint: string): string[] {  const loaded = tx.meta?.loadedAddresses;  const keys = [...tx.transaction.message.accountKeys, ...(loaded?.writable ?? []), ...(loaded?.readonly ?? [])];  const all = [...tx.transaction.message.instructions, ...(tx.meta?.innerInstructions ?? []).flatMap((i) => i.instructions)];  return all.flatMap((ix) => {    const d = b58.encode(ix.data);    const name = d.length === 1 ? NAMES[d[0]] : undefined;    return name && keys[ix.programIdIndex] === program && keys[ix.accounts[1]] === mint ? [`${name} ${keys[ix.accounts[0]]}`] : [];  });}async function check(mint: string): Promise<string[]> {  const { freeze, program, defaultState } = await readMint(mint);  const out = [`${mint} freeze=${freeze ?? "none"} default=${defaultState}`];  if (!freeze) return out;  const trail: string[] = [], found: string[] = [], failed: string[] = [];  let read = 0, nulls = 0, before: Signature | undefined;  for (let page = 0; page < PAGES && Date.now() < DEADLINE; page++) {    let sigs;    try { sigs = await rpc.getSignaturesForAddress(address(freeze), { limit: LOOK, before }).send(); }    catch (e) { failed.push(`history ${text(e)}`); break; }    if (sigs.length === 0) { if (page === 0) trail.push("no signatures"); break; }    before = sigs[sigs.length - 1].signature;    for (const s of sigs) {      if (Date.now() > DEADLINE) break;      trail.push(`${s.signature} ${s.blockTime ? new Date(Number(s.blockTime) * 1000).toISOString() : "no blockTime"}`);      if (s.err) continue;      try {        const tx = await rpc.getTransaction(s.signature, { maxSupportedTransactionVersion: 1, encoding: "json" }).send();        if (!tx) { nulls++; continue; }        read++;        found.push(...events(tx as unknown as Tx, program, mint).map((e) => `${e} ${s.signature}`));      } catch (e) { failed.push(`${s.signature} ${text(e)}`); }    }    // Older signatures sit further below the ledger floor: page on only past a page of skipped failed transactions.    if (read > 0 || nulls > 0 || failed.length > 0 || sigs.length < LOOK) break;  }  out.push(`  ${read} transactions read, ${found.length} freeze or thaw events`);  out.push(`  ${nulls} null below the ledger floor`);  for (const t of trail) out.push(`  ${t}`);  for (const f of [...found, ...failed.map((x) => `failed ${x}`)]) out.push(`  ${f}`);  return out;}const results = await Promise.allSettled(mints.map(check));results.forEach((r, i) => {  console.log(r.status === "fulfilled" ? r.value.join("\n") : `${mints[i]} read failed: ${text(r.reason)}`);});

run: CARBIUM_KEY=$CARBIUM_KEY node main.ts <mint1> <mint2>

A mint prints one line with its authority and its default account state. Under it come the number of transactions read with the event count, then a line counting the nulls as below the ledger floor, then every signature with its blockTime, then one line per event with the instruction name, the token account and the signature. Every call is settled on its own. A mint that fails to read prints its own line, a failed history call or transaction read prints a failed line, an authority whose newest page is empty prints no signatures, and the other mints still print.

The match is an instruction of the mint's token program whose data is one byte, 10 for FreezeAccount and 11 for ThawAccount, with this mint as its second account. The script checks the top-level instructions and the inner ones, so it finds the event whether the authority signed directly or a multisig program called the token program for it, as long as the authority's address is in the transaction. Account 0 of the instruction is the token account, and the event line prints it.

CallCellsFreeDevBusinessPro
getAccountInfo100.51550400
getSignaturesForAddress500.241.2100500
getTransaction500.241.2525

The columns after the cells are requests per second on each plan. A default run reads 3 accounts and makes 3 signature calls, and its first pass makes at most 15 getTransaction calls. Those spend 750 of the 1,024 cells that Free, Dev and Business absorb as a burst. A further page adds one 50-cell signature call and up to 250 cells for its transactions. On Free that class refills at 0.24 calls a second, so a second run soon after the first gets 429s. On a low plan, shorten the mint list to stay inside its limits.

05

Token-2022 default frozen state

A Token-2022 mint can carry the default account state extension. When it is set to frozen, every new token account of that mint starts frozen and stays unusable until the freeze authority thaws it. That turns a blacklist into an allowlist: the thaw is the approval, and the ThawAccount events in the authority's history list the accounts that were approved.

The script prints default=frozen for such a mint, default=initialized when the extension names the normal state, and default=none when the mint has no such extension. The freeze authority is also the key that can change the default later, so a screen that saw initialized last month is worth repeating.

For an issuer running this flow, thaw events track new customers being approved and freeze events track enforcement, so count the two separately in any report.

06

Where it ends

  • A page is LOOK signatures, five by default, and the script stops at the first page that reads a transaction. An authority also signs mints, burns and routine moves, so those five may hold no freeze. To cover more, raise LOOK, remembering that each extra signature costs a 50-cell getTransaction and that getSignaturesForAddress reads from Carbium's own address index, which keeps up to 30 days. An empty page past 30 days is the index's age limit, and the address may have older transactions.
  • getTransaction can answer null for a signature that the index lists, because index pages reach below the validator's ledger floor. An authority that rarely signs can have its newest five below the floor too. The script counts those nulls on their own line and stops there, since older signatures sit further below the floor and paging back cannot reach a readable transaction.
  • A mint with freeze=none has nothing to watch, and nothing can be added later.
  • Program-side blocks leave no FreezeAccount behind. A transfer hook or a deny list inside your own program rejects transfers by its own rules, so read that program's code and follow its upgrades with a program upgrade watcher.
  • The script reads a window and does not push. For live alerts open logsSubscribe with a mention of the authority and match the log lines Instruction: FreezeAccount and Instruction: ThawAccount. That subscription opens at 25 credits, then costs 20 credits per MiB sent.
  • The chain shows that a key signed a freeze. Why it did, and who owns the key, come from the issuer.
07

When it goes wrong

what goes wrongwhat to do
getTransaction answers -32015 for a transaction the signature list returned.The transaction is version 1. Pass maxSupportedTransactionVersion: 1 with an encoding.
A mint known to freeze accounts shows zero events.The page read held other instructions, or the authority changed hands. Re-read freezeAuthority, then raise LOOK to read more signatures inside the 30-day index.
getTransaction returns null for a signature the list just gave.Index pages reach below the validator's ledger floor, so a signature can have no transaction to return, even among an authority's newest five. Count it on the null line. Older signatures sit further below the floor, so paging back reaches no readable transaction.
Several getTransaction calls fail with 429 on a low plan.Each costs 50 cells and Free allows 0.24 a second. Shorten the mint list, read fewer signatures, or move to a plan with a higher rate.
A freeze event is filed against the wrong wallet.The event line prints the token account, which is account 0 of the instruction, and a wallet can own several. Read that account's owner field with getAccountInfo to file the event against its wallet.
Frozen accounts stay frozen after the issuer is gone.A cleared freeze authority cannot be set again, so nobody can thaw. Treat freeze=none on a mint with frozen accounts as permanent and record it.
08

Questions

Can I hard code a blacklist function in a Solana smart contract?

In a program you write, yes: its instructions can check a deny list. A plain token transfer never calls your program, so that list does not stop it. The token's own tools for that are the freeze authority and, on Token-2022, a transfer hook.

Does a freeze take the tokens from the holder?

No. The balance stays in the token account and the owner still holds it, but cannot move it until a thaw. A Token-2022 permanent delegate is a separate power that can move or burn tokens.

How do I tell a freeze from a thaw in the results?

Each event line starts with the instruction name, so FreezeAccount is a freeze and ThawAccount is a thaw. Read the token account's current state to see which one came last.

Can the freeze authority be removed?

Yes. A SetAuthority to none clears it and it cannot be set again, so no account of that mint can be frozen or thawed after that.