services
Get a key

library / Blockchain ideas / Payment tools / BI0095

Solana Pay link inspector

An inspector for solana: links. It classifies a link as a transfer request or a transaction request, parses a transfer's fields, and checks the recipient, mint, amount precision, token account and reference against chain state. Read-only.

By Carbium · Payment tools · BI0095 · updated 2026-11-22

01

Two kinds of link

Both kinds start with solana:, and the text after it tells them apart. A transfer request carries a recipient address and the payment terms in the query string. A transaction request carries an https URL, and the wallet asks that server what to sign. The inspector reads this difference first, because every later step depends on it.

PropertyTransfer requestTransaction request
Text after solana:A recipient address, then ?amount=...An https URL, percent-encoded when it has its own query
Who builds the transactionThe wallet, from the fieldsThe server behind the URL
What the wallet sendsNothing, it only reads the linkA GET for the label and icon, then a POST with the payer's address as account
What comes backNo reply is neededA base64 transaction and an optional message
What you can check before the payer scansEvery field, against chain stateThe URL scheme only, since the transaction exists once the server is asked
Typical useA fixed price at a checkoutCarts, mints and prices computed per payer

For a checkout the choice follows from one question: can the payment be written as one transfer of a known amount? If it can, a transfer request is smaller, needs no server to keep running, and can be validated completely before the QR code is shown. If the transaction has to be built per payer, because the price depends on who pays or a program must run, your server answers a transaction request.

!The inspector never calls a transaction request URL. A POST with an account hands that server an address and returns a transaction chosen by whoever runs it. Judging that transaction needs a wallet's simulation and a person's approval, and a read-only tool has neither.
02

Fields of a transfer request

  • recipient: the address right after solana:. It is a wallet address that holds SOL, and a token account is the wrong value there. For a token payment the wallet derives the recipient's token account itself.
  • amount: a decimal number in the unit people read. With spl-token set, 1.5 is one and a half tokens, and without it one and a half SOL. Lamports and base units never appear. Left out, the wallet asks the payer.
  • spl-token: the mint address of the token. Absent means SOL.
  • reference: one or more public keys, written as a repeated reference=. The wallet adds each as a read-only key on the transfer, so the payment shows up when you list the signatures of that key. This is how a checkout finds its payment.
  • label, message and memo: text. The wallet shows the first two, and memo goes into a memo instruction on the transaction.

A link written as amount=1000000 for one USDC asks for a million USDC. USDC has 6 decimals, so 0.01 passes the precision check and 0.0000001 fails it with seven decimal places.

Matching a payment after the wallet sends it is a separate job, covered in Solana Pay confirmation. The inspector stops before the payer scans.

03

Checks against chain state

CheckCallFails when
Recipient is a system accountgetAccountInfoThe account is empty or owned by a program, such as a token account pasted by mistake. A wallet that was never funded fails this row yet can still be paid
Mint existsgetAccountInfo, then getTokenSupplyThe address holds no token mint. getTokenSupply supplies the decimals
Amount fits decimalsnoneThe value is not a positive decimal, or has more fractional digits than the mint allows (9 for SOL)
Recipient token account existsgetAccountInfo on the derived addressNothing lives at the associated token address, so the payment has to create it first
Reference unusedgetSignaturesForAddressThe key already has a signature, and a later confirmation would match the old payment

Token-2022 mints change one step. An associated token address comes from the owner, the token program and the mint, so a Token-2022 mint gives a different address than a classic one. The code reads the mint's owner and uses it in the derivation, which is why the mint check runs before the others. Associated token address lookup covers the derivation on its own.

The reference check sees only what the 30-day address index holds, so a key used longer ago looks unused. Generate a fresh reference for every order and the window never matters.

04

main.ts

With no argument the code builds a link so you can run it cold. It lists the newest signatures on the USDC mint, reads one transaction and takes its fee payer as the recipient, adds a random 32-byte reference and sets amount=0.01. That recipient is a live wallet, so the checks read real accounts, and whether it holds a USDC account is what the run finds out. Pass any link as the first argument to inspect it instead.

  1. Split the link at the first ? and decode the part before it. An http or https prefix there means a transaction request: print the URL and stop.
  2. Otherwise read amount, spl-token and each reference, and print the fields with any label, message or memo.
  3. Read the mint with getAccountInfo and getTokenSupply to learn the token program and the decimals.
  4. Run the recipient, amount, token account and reference checks together.
  5. Print pass or fail with a short reason for each.
main.ts
// BI0095 · Solana Pay link inspector// https://carbium.sh/library/blockchainideas/solana-pay-link-inspector// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { address, createDefaultRpcTransport, createSolanaRpcFromTransport, getAddressDecoder, getAddressEncoder, getProgramDerivedAddress } from "@solana/kit";const key = process.env.CARBIUM_KEY ?? "";if (!key) { console.error("Set CARBIUM_KEY, then run: node main.ts [solana: link]"); process.exit(1); }const rpc = createSolanaRpcFromTransport(  createDefaultRpcTransport({ url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh", headers: { "x-api-key": key } }),);const commitment = "confirmed";const [USDC, SYSTEM, TOKEN, TOKEN_2022, ATA_PROGRAM] = ["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "11111111111111111111111111111111", "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"];type Row = [string, boolean, string];const run = (name: string, f: () => Promise<[boolean, string]>): Promise<Row> =>  f().then((r): Row => [name, ...r], (e): Row => [name, false, `call failed: ${e instanceof Error ? e.message : e}`]);// No argument: build a sample transfer link from the USDC mint and a recent fee payer.async function sampleLink() {  const sigs = await rpc.getSignaturesForAddress(address(USDC), { limit: 10, commitment }).send();  for (const s of sigs.filter((x) => x.err === null)) {    try {      const tx = (await rpc.getTransaction(s.signature, { commitment, encoding: "json", maxSupportedTransactionVersion: 1 }).send()) as unknown as { transaction: { message: { accountKeys: string[] } } } | null;      const payer = tx?.transaction.message.accountKeys[0];      const ref = getAddressDecoder().decode(crypto.getRandomValues(new Uint8Array(32)));      if (payer) return `solana:${payer}?amount=0.01&spl-token=${USDC}&reference=${ref}&label=Demo`;    } catch {}  }  throw new Error("no readable recent transaction to take a recipient from");}async function main() {  const link = process.argv[2] ?? (await sampleLink());  console.log(link);  if (!link.startsWith("solana:")) throw new Error("not a solana: link");  const [path = "", query = ""] = link.slice(7).split("?");  const target = decodeURIComponent(path);  if (/^https?:\/\//.test(target)) {    console.log(`kind: transaction request, url ${target}, ${target.startsWith("https") ? "https" : "http (https is required)"}`);    console.log("no chain checks: the wallet fetches this URL and this tool never does");    return;  }  const q = new URLSearchParams(query);  const [amount, mint, refs] = [q.get("amount"), q.get("spl-token"), q.getAll("reference")];  console.log(`kind: transfer request, recipient ${target}, amount ${amount ?? "(wallet asks)"}, token ${mint ?? "SOL"}, ${refs.length} reference(s)`);  for (const f of ["label", "message", "memo"]) if (q.has(f)) console.log(`${f}: ${q.get(f)}`);  let decimals = 9;  let program = "";  const rows: Row[] = [];  if (mint) {    rows.push(await run("mint exists", async () => {      const { value } = await rpc.getAccountInfo(address(mint), { encoding: "base64", commitment }).send();      if (!value || (value.owner !== TOKEN && value.owner !== TOKEN_2022)) return [false, "no token mint at this address"];      program = value.owner;      decimals = (await rpc.getTokenSupply(address(mint), { commitment }).send()).value.decimals;      return [true, `${decimals} decimals, token program ${program.slice(0, 8)}`];    }));  }  const jobs = [    run("recipient is a system account", async () => {      const { value } = await rpc.getAccountInfo(address(target), { encoding: "base64", commitment }).send();      if (!value) return [false, "no account at this address yet"];      return [value.owner === SYSTEM, `owner ${value.owner.slice(0, 8)}, ${value.lamports} lamports`];    }),    run("amount fits decimals", async () => {      if (amount === null) return [true, "none, the wallet asks the payer"];      const places = amount.split(".")[1]?.length ?? 0;      return [/^\d+(\.\d+)?$/.test(amount) && Number(amount) > 0 && places <= decimals, `${places} decimal places, ${decimals} allowed`];    }),    ...(program ? [run("recipient token account exists", async () => {      const enc = getAddressEncoder();      const [ata] = await getProgramDerivedAddress({ programAddress: address(ATA_PROGRAM), seeds: [enc.encode(address(target)), enc.encode(address(program)), enc.encode(address(mint!))] });      const { value } = await rpc.getAccountInfo(ata, { encoding: "base64", commitment }).send();      return [value !== null, `${ata.slice(0, 8)} ${value ? "found" : "missing, the payment must create it"}`];    })] : []),    ...refs.map((r) => run(`reference ${r.slice(0, 8)} unused`, async () => {      const sigs = await rpc.getSignaturesForAddress(address(r), { limit: 1, commitment }).send();      return [sigs.length === 0, sigs.length === 0 ? "no signatures" : `already used by ${sigs[0]!.signature.slice(0, 8)}`];    })),  ];  rows.push(...(await Promise.all(jobs)));  for (const [name, ok, note] of rows) console.log(`${ok ? "pass" : "fail"}  ${name}: ${note}`);}main().catch((e) => {  console.error(e instanceof Error ? e.message : e);  process.exit(1);});

run: CARBIUM_KEY=<YOUR_KEY> node main.ts

Every call asks for confirmed commitment, set in the code so the choice is visible. The transaction read passes maxSupportedTransactionVersion 1, because mainnet carries v1 transactions and a read left at 0 answers -32015 for one.

Each check runs inside its own failure handler, so a call that errors becomes a fail row with its message and the others still print. A reference is only ever listed as an account key, so a random 32-byte value works for the look-up.

06

Where it ends

  • A transaction request gets a classification and a scheme check and nothing more. Whether the server answers, and what it builds, is for a wallet to find out with a simulation.
  • Passing every check shows the link can be paid. The inspector cannot see how a wallet displays the label and message, or whether a payer approves.
  • Any system account passes the recipient check, so it cannot tell whether the wallet is the one you meant.
  • The sample recipient is a fee payer that touched the mint. The token account row fails when the sampled fee payer holds no USDC account.
  • Token-2022 extensions such as a transfer fee are not read. A mint with one still passes.
  • Reference history stops at the 30-day index.
07

When it goes wrong

what goes wrongwhat to do
The mint check fails for a token that exists.The address in spl-token is a token account or a wallet. Put the mint address there.
The amount check fails on a link that one wallet accepts.The amount has more decimal places than the mint. Round it to the mint's decimals so every wallet reads the same number.
The recipient check says the account is not a system account.The link names a token account or a program-owned address. Use the owner's wallet address and let the wallet derive the token account.
The token account check fails for a good recipient.The wallet has never held this token. The payment has to include an instruction that creates the associated token account, so decide who pays for it before the link goes out.
A reference reads as used.The key already appears in a transaction. Generate a new key for each order and never reuse one.
getTransaction answers -32015 in the sample run.The read left out maxSupportedTransactionVersion or set it to 0, and the transaction is v1. Pass 1.
08

Questions

Which kind of link should a checkout use?

A transfer request when the payment is one transfer of a known amount to your wallet. A transaction request when the price or the instructions depend on the payer or on a program. Only the first can be checked completely before it is shown.

Does amount take lamports?

No. It is in whole units, SOL for a SOL link and token units for a token link. The wallet converts it with the mint's decimals.

Can the inspector validate the transaction behind a transaction request?

Not from the link. The transaction exists only after the server answers a POST for a given account, so a wallet or a simulator with a payer address has to check it.

Why check a reference I generated myself?

A link from someone else, or a key reused from your own store, can carry a reference that already has transactions, and a later confirmation would match the old one. A fresh key lists empty.

Does it work with Token-2022 mints?

Yes for the address derivation, because the code reads the mint's owner and uses that program in it. Extensions on the mint are not read.