library / Blockchain ideas / Consumer and social / BI0120
Receive-address QR card
The content of a printable receive card for any Solana address: the string to encode as a QR code, the address in text, and a chain-read status line saying whether the address is a funded wallet, an empty one or not a wallet.
Who uses it
A creator, a market stall, a club or a hackathon team wants one thing on a screen or a printed sheet: a square that a phone camera turns into a wallet address. Anyone who has pasted a 44-character address into a chat knows the reason. One wrong character sends funds to an address nobody controls, and a scan removes the typing.
The card is the small page around that square. It shows the QR code, the address in plain text under it, and one line saying whether the address is ready to receive. The code builds that content from an address and reads the chain first, so you can refuse to print a card for an address that is empty, a program or a token account.
- A tip jar on a profile page or a donation link in a stream description.
- A printed card on a stall table or an event desk.
- A wallet screen in an app, with a Receive button that opens the card.
- An email signature or an invoice footer.
What the card holds
| Part | Content | Where it comes from |
|---|---|---|
| QR payload | solana:<address>, with amount in SOL and label when you set them | built in the code, no call |
| Address text | the full base58 address under the QR, so a person can compare it | the input |
| Status line | funded wallet, empty address, program, or owned by another program | owner and executable from getAccountInfo |
| Balance | SOL on the account at confirmed | lamports from getAccountInfo |
| Last activity | time of the newest signature, or none in the index window | blockTime from getSignaturesForAddress |
| First-deposit minimum | lamports a never-funded address must receive first, shown in the empty verdict | getMinimumBalanceForRentExemption for 0 data bytes |
The payload follows the Solana Pay transfer request format: solana: followed by the recipient, then optional query fields such as amount (in SOL, decimals allowed), label, message, memo and spl-token. A wallet that reads the format opens a send screen with the recipient filled in. A wallet that only understands a bare address still gets the text under the QR, which is why the card carries both.
The image itself comes from any QR library, in the browser or on a server. The payload is short, so the square stays coarse and scans from a distance. Pick error correction level M or higher if the card will be printed, since paper gets creased and stickers get scratched.
The build
One file, @solana/kit and Node 24. It is read-only: no private key, nothing sent. Run it with an address and it prints the card content, plus anything that failed on the way.
- Read the address from the command line and refuse a string that is not a valid address before any call is made.
- Create one RPC client for https://services.carbium.sh and reuse it.
- Run three reads together and settle each, so one failing call leaves the others on screen: the account, the newest signature, and the rent minimum for an account with no data.
- Turn the account into a verdict. No account means an empty address. An executable account is a program. An owner other than the System Program means a token account or another program's account. Anything else is a wallet.
- Build the solana: payload from the address and the optional AMOUNT and LABEL.
- Print the payload, the address, the verdict, the balance and the last activity.
// BI0120 · Receive-address QR card// https://carbium.sh/library/blockchainideas/receive-address-qr-card// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { address, createDefaultRpcTransport, createSolanaRpcFromTransport, type Address } from "@solana/kit";const key = process.env.CARBIUM_KEY ?? "";const input = (process.argv[2] ?? "").trim();if (!key || !input) { console.error("Set CARBIUM_KEY to your Carbium API key and pass the receive address: node main.ts <address>"); process.exit(1);}let addr: Address;try { addr = address(input);} catch { console.error("That is not a valid Solana address. Copy it again from the wallet's receive screen."); process.exit(1);}const amount = process.env.AMOUNT; // in SOL, decimals allowed, optionalconst label = process.env.LABEL;if (amount && !(Number(amount) > 0)) { console.error("AMOUNT must be a positive number of SOL."); process.exit(1);}const rpc = createSolanaRpcFromTransport( createDefaultRpcTransport({ url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh", headers: { "x-api-key": key }, }),);const SYSTEM = "11111111111111111111111111111111";// Three independent reads, each settled so one failure leaves the rest. The first two name confirmed; kit fills it in for the rent call.const results = await Promise.allSettled([ rpc.getAccountInfo(addr, { commitment: "confirmed", encoding: "base64" }).send(), rpc.getSignaturesForAddress(addr, { limit: 1, commitment: "confirmed" }).send(), rpc.getMinimumBalanceForRentExemption(0n).send(),]);const names = ["getAccountInfo", "getSignaturesForAddress", "getMinimumBalanceForRentExemption"];results.forEach((r, i) => { if (r.status === "rejected") console.error(`${names[i]} failed: ${r.reason instanceof Error ? r.reason.message : String(r.reason)}`);});const [acct, sigs, rent] = results;const a = acct.status === "fulfilled" ? acct.value.value : undefined;const minimum = rent.status === "fulfilled" ? String(rent.value) : "unknown";let verdict: string;if (a === undefined) verdict = "unknown: the account read failed, do not print this card";else if (a === null) verdict = `empty: nothing at this address yet, the first SOL sent must be at least ${minimum} lamports`;else if (a.executable) verdict = "program: this address runs code and is not a wallet";else if (a.owner !== SYSTEM) verdict = `owned by another program (${a.owner}): a token account or program account, not a wallet`;else verdict = "ready: a funded wallet account";const q = [amount ? `amount=${amount}` : "", label ? `label=${encodeURIComponent(label)}` : ""].filter(Boolean);const payload = `solana:${addr}${q.length ? `?${q.join("&")}` : ""}`;let last = "unknown: the listing call failed";if (sigs.status === "fulfilled") { const s = sigs.value[0]; last = !s ? "none in the 30-day index" : s.blockTime === null ? "newest signature has no block time" : new Date(Number(s.blockTime) * 1000).toISOString();}console.log(`QR payload ${payload}`);console.log(`Address ${addr}`);console.log(`Status ${verdict}`);console.log(`Balance ${a ? `${Number(a.lamports) / 1e9} SOL` : "n/a"}`);console.log(`Last activity ${last}`);
run: CARBIUM_KEY=<YOUR_KEY> node main.ts <ADDRESS>
The account read and the signature listing name confirmed in the call. The rent call leaves commitment out, and @solana/kit 8.6.0 fills in confirmed for it.
A system account holding no data must hold at least the rent-exempt minimum, so the first SOL sent to a never-funded address has to cover it. The card prints that figure, and a sender who tries less sees the transfer fail.
What it costs
getAccountInfo is an account read at 10 cells, and getSignaturesForAddress costs 50 cells, so a card is 60 cells plus the rent-minimum call. On Free and Dev the signature listing has the lower rate and sets the pace. On Business and Pro the account read does.
| Plan | getAccountInfo rate | getSignaturesForAddress rate | Cards per second, at most |
|---|---|---|---|
| Free | 0.5 req/s | 0.24 req/s | 0.24 |
| Dev | 15 req/s | 1.2 req/s | 1.2 |
| Business | 50 req/s | 100 req/s | 50 |
| Pro | 400 req/s | 500 req/s | 400 |
The last column takes the lower of the two rates and ignores the rent call. A card only changes when the address does, so build it once, store the result next to the user's profile and serve that. Limits are per account, so the other tools on your keys draw on the same budget.
What to add next
- A pre-filled amount per order: pass AMOUNT and LABEL, and each order gets its own QR with the shop name and the sum already in the sender's wallet.
- A token card: add spl-token=<mint> to the payload. The sender can create your token account for that mint in the same transaction at their own cost, and Associated token address lookup shows where it will live.
- A payment watch: once the card is on screen, listen for the money. A plain SOL wallet sends no accountSubscribe notifications, so open logsSubscribe with a mention of the address and read the balance when one arrives. The Multi-address deposit monitor has the loop.
- A link check on the receiving side: the Solana Pay link inspector reads a solana: link back and names every field in it.
- The minimum in numbers: Rent-exempt minimum calculator explains where the first-deposit figure comes from.
Where it ends
- A QR code proves an address and says nothing about its owner. A sticker pasted over a printed card sends payments elsewhere, so keep the address text under the square and tell people to compare it.
- The check is one snapshot. A wallet whose keys were lost looks the same as a healthy one, and an address can change state after the card is built.
- Last activity comes from the 30-day address index. A wallet with nothing in that window may still have older history, and an empty page past 30 days marks the index's age limit.
- An address inside an exchange or a custody service may need a memo or tag from that service. The chain cannot say so, and the card cannot either.
- The amount field in the payload counts SOL, so 0.1 means a tenth of a SOL. A token amount uses the token's own decimals and needs the spl-token field, so the code leaves it out.
- The code builds the payload and does not draw the image. QR drawing is a separate library in your page or server.
When it goes wrong
| what goes wrong | what to do |
|---|---|
| The code stops with an address error before any call. | The string is not a valid base58 address, often from a trailing space or a character lost in a copy. Trim it and paste it again from the wallet's receive screen. |
| Every call answers 401. | The key is unknown at the door. Attach the whole key in CARBIUM_KEY, with no spaces or missing characters. |
| The signature call answers 429 on a Free key. | That method allows 0.24 req/s there. Build each card once and store it, and check what else on the account is calling, since the budget is shared across its keys. |
| The verdict says the address is owned by another program, and the user insists it is their wallet. | They copied a token account or a program account from a token list. Show the wallet address from the wallet's receive screen instead. |
| Last activity reads none for a wallet that has been used. | Its last transaction is older than the 30-day address index. The wallet is fine, and the card should treat that line as a hint only. |
| One of the three reads fails and the card shows a gap. | The code prints which call failed and keeps the others. Run it again, and do not print a card whose status line reads unknown. |
Questions
Should the QR hold the bare address or a solana: link?
A solana: link works in wallets that read Solana Pay and lets you add an amount and a label. A bare address works in any wallet that accepts a pasted address. Print the address text under the QR either way.
Does the sender's wallet need to support Solana Pay?
For the pre-filled send screen, yes. A wallet without it can still scan the square and read the address inside the link, so show the address text too.
Is it safe to publish my address?
Yes for receiving funds, since nobody can move money out with an address. The cost is privacy: anyone can read the balance and history of a public address.
Why check the chain if the QR only holds a string?
A typo, a token account and a program address all pass as valid strings, and the sender finds out after a failed or lost transfer. The read names a token account or a program by its owner, and a typo usually shows up as an empty address where you expected a funded wallet.