Read a Solana token's real rules with one RPC call (no SDK)
DEV Community

Read a Solana token's real rules with one RPC call (no SDK)

A token page can say anything. The mint account cannot lie.

This post shows how to read a Solana token's real rules with one standard RPC call: no SDK, no wallet, no keys. We use it every Monday to re-check one token, and it recently corrected our own documentation.

The one call: getAccountInfo with jsonParsed

Every SPL token has a mint account. Ask any Solana RPC node for it with encoding: "jsonParsed" and the node decodes it for you:

// read-mint.mjs Β· Node 18+ (built-in fetch) Β· read-only
const MINT = process.argv[2];
const RPC = process.argv[3] || 'https://api.mainnet-beta.solana.com';
const res = await fetch(RPC, {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'getAccountInfo',
    params: [MINT, { encoding: 'jsonParsed', commitment: 'finalized' }],
  }),
});
const { result, error } = await res.json();
if (error || !result?.value) throw new Error(JSON.stringify(error ?? 'account not found'));
const v = result.value;
const info = v.data?.parsed?.info ?? {};
const exts = info.extensions ?? [];
const has = name => exts.find(e => e.extension === name);
console.log('slot ', result.context.slot);
console.log('owner program ', v.owner);
console.log('account type ', v.data?.parsed?.type);
console.log('decimals ', info.decimals);
console.log('mint authority ', info.mintAuthority ?? 'none (revoked)');
console.log('freeze authority ', info.freezeAuthority ?? 'none (revoked)');
console.log('extensions ', exts.map(e => e.extension).join(', ') || 'none');
console.log('transfer fee ', has('transferFeeConfig') ? JSON.stringify(has('transferFeeConfig').state.newerTransferFee) : 'none');
console.log('transfer hook ', has('transferHook') ? JSON.stringify(has('transferHook').state) : 'none');
console.log('permanent delegate', has('permanentDelegate') ? JSON.stringify(has('permanentDelegate').state) : 'none');

Run it:

node read-mint.mjs WENWENvqqNya429ubCdR81ZmD69brwQaaBYY6p3LCpk

How to read the answer

  • owner program - Tokenkeg… = the original SPL Token program, which cannot carry extensions. TokenzQd… = Token-2022, where extensions are possible. Anything else is not a token mint.
  • mint authority - If set, more tokens can be created.
  • freeze authority - If set, a holder's account can be frozen.
  • transferFeeConfig - Token-2022 only: a fee withheld on every transfer, rounded up by the program.
  • transferHook - Token-2022 only: a program that runs on every transfer.
  • permanentDelegate - Token-2022 only: an address that can move or burn tokens from any holder.

None of these is good or bad by itself. A settlement token should have a freeze authority. The point is to know before you hold or integrate.

A real result

Read at finalized slot 468049071 for the WEN mint:

  • owner program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
  • account type mint
  • decimals 5
  • mint authority none (revoked)
  • freeze authority none (revoked)
  • extensions none
  • transfer fee none

The owner is the original SPL Token program, so a transfer fee is not just absent; it is impossible.

This corrected us. Our almanac had said that WEN's January 2024 launch "stress-tested Token-2022". The mint says otherwise: WEN connects to Token-2022 through its history (the poem behind it was minted as an NFT with WNS, a standard built on Token-2022), while the fungible token itself lives on the original program. The launch stress-tested Solana and Jupiter's launchpad. We fixed 23 sentences in the open and kept a public note of what changed.

Make it repeat itself: a weekly GitHub Action

A check you run once is a screenshot. A check that reruns is evidence. Put the script in your repo and add a workflow:

name: Check mint
on:
  workflow_dispatch:
  schedule:
    - cron: "23 5 * * 1" # every Monday
permissions:
  contents: read
jobs:
  mint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-node@v5
        with:
          node-version: 22
      - run: node read-mint.mjs WENWENvqqNya429ubCdR81ZmD69brwQaaBYY6p3LCpk

In our version the script also appends its output to $GITHUB_STEP_SUMMARY, so the result appears on the run page for anyone to see, with the slot it was read at.

Two habits

  • Read the program before the page. One call tells you whether extensions are even possible.
  • Re-read on a schedule. Authorities can be revoked or, on some tokens, changed. A dated, rerunnable read beats a claim.

Read-only code. No wallet, no keys. Educational content, not financial advice. The full script and the weekly job (Apache-2.0): https://github.com/wen-watt/wen-watt.github.io/blob/main/tools/check-wen-mint.mjs

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.