---
id: BI0011
title: "RWA supply and authority monitor"
url: https://carbium.sh/library/blockchainideas/rwa-supply-and-authority-monitor
collection: Blockchain ideas
category: RWA and compliance
revision: 1
updated: 2026-11-22
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# RWA supply and authority monitor

A watcher that reads the mint accounts of the tokenized assets you issue or hold, keeps a baseline in SQLite and alerts when supply swings or a mint, freeze or permanent-delegate authority changes.

## Who uses it

A tokenized real-world asset on Solana is an ordinary SPL token mint with a legal structure around it, and that structure leans on a few keys. The mint authority can create more supply. The freeze authority can lock any holder's token account. A Token-2022 mint can also name a permanent delegate, which can move or burn tokens from any account of that mint. What the token means in practice depends on who holds those keys and when they change.

Three readers want to know when something moves. An issuer's compliance team wants an independent record that only the expected multisig holds the keys and that supply follows subscriptions and redemptions. A wallet or exchange that lists the token wants a message the moment a key changes hands. A hackathon team wants a dashboard of key changes across a basket of tokenized assets, and the code defaults to three public mints, so a demo needs no cooperation from an issuer.

Everything comes from one HTTPS endpoint, `https://services.carbium.sh`. The monitor holds no signing key and sends no transactions. For the plain balance read that sits underneath this, see [SPL token balance](https://carbium.sh/library/howsolana/spl-token-balance).

## What it watches

Each watched mint is one row in a baseline table, and every change becomes one row in an event table. All the fields come from one parsed read of the mint account.

| Field | Where it comes from | Why it matters |
|---|---|---|
| Supply | `info.supply`, an integer in base units | Mints and burns show up as movement. The issuer's published reserve figure is the number to compare it with, outside this tool. |
| Mint authority | `info.mintAuthority` | The address that can create more supply. None means supply is fixed. |
| Freeze authority | `info.freezeAuthority` | The address that can freeze a holder's token account. None means nobody can. |
| Permanent delegate | the `permanentDelegate` entry in `info.extensions`, Token-2022 mints only | The address that can move or burn tokens from any holder's account. |
| Event log | the `event` table in SQLite | Each alert with its time, the old value and the new one. |

An authority change alerts on any difference, including a change to none. Setting an authority to none cannot be undone, so that key never comes back, and the event row keeps the last address that held it.

Supply alerts when it differs from the baseline by `SUPPLY_PCT`, which defaults to 1 percent. The supply baseline moves only when a supply alert fires, so small moves spread over many polls add up until they cross `SUPPLY_PCT` and alert once.

## The build

The monitor is one file that needs `@solana/kit` and what Node 24 ships, including `node:sqlite`. It is read-only.

1. Read `MINTS`, a comma separated list of mint addresses. It defaults to three public mints so a first run prints something. An entry that is not a valid address stops the start and names the entry. Open the SQLite file at `DB_PATH` with two tables, `snap` for the baseline and `event` for the alerts. If the file cannot be opened, it prints that and keeps the baseline in memory for the run.
2. Create the RPC client for `https://services.carbium.sh` once, at start.
3. Every `POLL_SECONDS` (30 by default), send `getMultipleAccounts` calls for the mints, at most 100 pubkeys per call, with `jsonParsed` encoding at commitment `finalized`.
4. For each mint, take the supply and the authorities from the parsed info. An address whose account is missing or is not a mint prints `no mint account found`.
5. Compare with the baseline. Each difference prints an `ALERT` line and inserts an event row. The first time a mint is seen it only sets the baseline.
6. A failed poll prints the error message and the next tick tries again.

Point `MINTS` at the tokens you care about. A mint you issue, a basket you hold or the token behind a product you integrate all work the same way, because the code has no RWA list of its own.

`main.ts` (run: `CARBIUM_KEY=<YOUR_KEY> node main.ts`)

```ts
// BI0011 · RWA supply and authority monitor
// https://carbium.sh/library/blockchainideas/rwa-supply-and-authority-monitor
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, isAddress } from "@solana/kit";
import { DatabaseSync } from "node:sqlite";

const key = process.env.CARBIUM_KEY;
if (!key) {
  console.error("Set CARBIUM_KEY to your Carbium API key.");
  process.exit(1);
}
// Defaults are public mints (USDC, USDY, PYUSD) so a first run prints something; MINTS takes yours.
const MINTS = (
  process.env.MINTS ??
  "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v,A1KLoBrKBde8Ty9qtNQUtq3C2ortoC3u7twggz7sEto6,2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo"
).split(",");
const bad = MINTS.find((m) => !isAddress(m));
if (bad !== undefined) {
  console.error(`MINTS has an invalid address: "${bad}"`);
  process.exit(1);
}
const PCT = Number(process.env.SUPPLY_PCT ?? 1); // supply move against the baseline that raises an alert
const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({ url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh", headers: { "x-api-key": key } }),
);
const path = process.env.DB_PATH ?? "rwa-monitor.db";
let db: DatabaseSync;
try {
  db = new DatabaseSync(path);
} catch {
  console.error(`cannot open ${path}, the baseline stays in memory for this run`);
  db = new DatabaseSync(":memory:");
}
db.exec(`create table if not exists snap (mint text primary key, supply text, mint_auth text, freeze_auth text, delegate text);
create table if not exists event (at text, mint text, kind text, old text, new text);`);
const get = db.prepare("select * from snap where mint = ?");
const put = db.prepare("insert or replace into snap values (?, ?, ?, ?, ?)");
const log = db.prepare("insert into event values (?, ?, ?, ?, ?)");
type Snap = { supply: string; mint_auth: string | null; freeze_auth: string | null; delegate: string | null };
type Info = {
  supply: string;
  mintAuthority: string | null;
  freezeAuthority: string | null;
  extensions?: { extension: string; state: { delegate?: string } }[];
};
function alert(mint: string, kind: string, was: string | null, now: string | null): void {
  console.log(`ALERT ${mint} ${kind}: ${was ?? "none"} to ${now ?? "none"}`);
  log.run(new Date().toISOString(), mint, kind, was, now);
}
async function poll(): Promise<void> {
  for (let s = 0; s < MINTS.length; s += 100) {
    const slice = MINTS.slice(s, s + 100); // a call takes at most 100 pubkeys below Pro
    const { value } = await rpc
      .getMultipleAccounts(slice.map((m) => address(m)), { encoding: "jsonParsed", commitment: "finalized" })
      .send();
    value.forEach((acct, i) => {
      const mint = slice[i];
      const parsed = (acct?.data as unknown as { parsed?: { type?: string; info?: Info } } | undefined)?.parsed;
      const info = parsed?.type === "mint" ? parsed.info : undefined;
      if (!info) {
        console.log(`${mint} no mint account found`);
        return;
      }
      const now: Snap = {
        supply: info.supply,
        mint_auth: info.mintAuthority,
        freeze_auth: info.freezeAuthority,
        delegate: info.extensions?.find((x) => x.extension === "permanentDelegate")?.state.delegate ?? null,
      };
      console.log(`${mint.slice(0, 8)} supply ${now.supply} mint ${now.mint_auth ?? "none"} freeze ${now.freeze_auth ?? "none"} delegate ${now.delegate ?? "none"}`);
      const old = get.get(mint) as unknown as Snap | undefined;
      let base = now.supply; // the supply baseline moves only when a supply alert fires
      if (old) {
        base = old.supply;
        for (const f of ["mint_auth", "freeze_auth", "delegate"] as const) {
          if (old[f] !== now[f]) alert(mint, f, old[f], now[f]);
        }
        // u64 supplies pass 2^53, so subtract as BigInt before turning the gap into a percent
        const pct = (Math.abs(Number(BigInt(now.supply) - BigInt(old.supply))) / (Number(old.supply) || 1)) * 100;
        if (pct >= PCT) {
          alert(mint, `supply (${pct.toFixed(2)}%)`, old.supply, now.supply);
          base = now.supply;
        }
      }
      put.run(mint, base, now.mint_auth, now.freeze_auth, now.delegate);
    });
  }
}
const tick = () => poll().catch((e) => console.error("poll failed:", e instanceof Error ? e.message : e));
void tick();
setInterval(tick, Number(process.env.POLL_SECONDS ?? 30) * 1000);
```

Point `DB_PATH` at a new file to start a fresh baseline.

## What it costs

One poll is one `getMultipleAccounts` call for every 100 mints. It charges 10 cells per pubkey and takes up to 300 pubkeys, but the 1,024-cell burst caps a call at 100 pubkeys below Pro, so the code sends slices of 100. Cells are the admission charge per call. The three default mints cost 30 cells a poll. At 30 seconds that is 120 polls an hour, or 3,600 cells. A hundred mints cost 1,000 cells a poll and 120,000 cells an hour.

| Plan | Credits | Account reads |
|---|---|---|
| Free ($0) | 500K once, at sign-up | 0.5 req/s |
| Dev ($20) | 10M per month | 15 req/s |
| Business ($250) | 50M per month | 50 req/s |
| Pro ($500) | 200M per month | 400 req/s |

Limits are per account, so other tools on the same keys draw on the same budget. Three mints every 30 seconds is 30 cells every 30 seconds, the weight of 0.1 account reads a second, under Free's 0.5. By that arithmetic about 15 mints fit under Free's rate at a 30 second gap. A longer list on Free wants a wider gap. A call over the rate gets a 429, which the monitor prints before it tries again at the next tick.

## What to add next

- Push alerts: open a `logsSubscribe` with `mentions` on each mint. A logs-mentions subscription opens at 25 credits and then costs 20 credits per MiB sent, and every transfer that names the mint is a notification, so a busy token streams more than a quiet one. Keep the poll as the baseline check and use the stream to wake it early.
- Find the transaction: when an alert fires, call `getSignaturesForAddress` on the mint (50 cells) and then `getTransaction` (50 cells) and read the instructions for the authority change. Pass `maxSupportedTransactionVersion: 1`, because absent or 0 it answers -32015 for a v1 transaction, and handle a null answer for an older signature. TransferChecked and other instructions name the mint too, so the newest signature is not always the change.
- An expected list: keep the multisig addresses you expect in a file and alert when a mint shows any other authority, even on first sight.
- Chat delivery: post each `ALERT` line to a channel, with the mint and the old and new values.

## Where it ends

- It reads on-chain state only. Supply is in base units and says nothing about the reserve, the net asset value or the custodian. Match it with the issuer's own attestation yourself.
- An authority is one address. A multisig or a program-owned account shows as a single key, and who stands behind it needs another lookup.
- Polling sees the state at each read. Two changes inside one gap, a key set and then set back, leave no trace. The gap is `POLL_SECONDS`, and a log subscription closes it.
- Only the permanent delegate is decoded from Token-2022 extensions. A transfer hook or an interest-bearing mint is not read, and an interest-bearing token shows a raw supply that differs from the amount a wallet displays.
- It cannot rank holders. `getTokenLargestAccounts` is not served here and answers -32601, which means do not retry, so concentration needs another route.
- The code finds that a change happened between two polls, and finding who made it uses `getSignaturesForAddress`, which reaches back 30 days at most. It records changes and does not judge whether a token is compliant.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| A mint prints `no mint account found`. | Check that the address is a mint on mainnet and not a wallet or a token account, since only an account whose parsed type is `mint` passes. An entry that is not a valid address stops the start and names the entry. A mistyped address that is still a valid address has no account and prints this line. |
| Every tick prints `poll failed` with an HTTP error. | Check that `CARBIUM_KEY` holds a live key of your account. The printed message never contains it. |
| The poll fails with a 429. | Widen `POLL_SECONDS`. A call costs 10 cells per mint and limits are shared across the account's keys, so check what else is calling. The next tick retries on its own. |
| A change made while the monitor was down never alerts. | The baseline lives in the file at `DB_PATH`, which is relative to the folder you start in. When that file is new, empty or lost, the first poll sets the baseline again without an alert, so a change made in the gap goes unseen. Use an absolute path, and note that `:memory:` starts empty each time. A start line saying the file cannot be opened means the baseline is held in memory and lost on exit, so start in a folder you can write to. |
| The delegate column always shows none on a Token-2022 mint. | The mint may carry no permanent delegate. Print `info.extensions` to see which extensions it has, since the monitor reads only `permanentDelegate`. |
| Supply alerts on a token that mints on a schedule. | Raise `SUPPLY_PCT`, or read the `event` table to see whether the moves match the issuer's published cycle before you tune anything. |

## Questions

### Does the monitor need a WebSocket?

No, it polls over HTTPS. A `logsSubscribe` on each mint gives push alerts and opens at 25 credits per subscription plus 20 credits per MiB sent. It is the first thing to add if the poll gap is too wide.

### How many mints can one monitor watch?

One `getMultipleAccounts` call takes up to 300 pubkeys at 10 cells each, but the 1,024-cell burst caps a call at 100 pubkeys below Pro, so on Free, Dev and Business the list splits above 100. The code sends slices of 100, so 300 mints are three calls and 3,000 cells a poll.

### Can it tell me who changed an authority?

Not by itself. It records that a value differs between two polls. Use `getSignaturesForAddress` on the mint, which has a 30 day reach, and `getTransaction` to find the instruction.

### Does it work on tokens that are not real-world assets?

Yes. It reads any SPL mint, and `MINTS` is the only list. Alerts on a stablecoin's authorities read the same as alerts on a tokenized fund.

## Related

- [SPL token balance](https://carbium.sh/library/howsolana/spl-token-balance) (How to use Solana, HS0001)
- [RPC rate-limit alerts](https://carbium.sh/library/usecase/rpc-rate-limit-alerts) (Use cases, UC0001)
- [carbium.sh/docs#rpc](https://carbium.sh/docs#rpc)
- [carbium.sh/docs#limits](https://carbium.sh/docs#limits)
- [carbium.sh/docs#auth](https://carbium.sh/docs#auth)
- [carbium.sh/docs#endpoints](https://carbium.sh/docs#endpoints)
- [carbium.sh/docs#errors](https://carbium.sh/docs#errors)
- [carbium.sh/docs#websocket](https://carbium.sh/docs#websocket)
