A till that can send money is a target. So we built one that cannot. Wen Counter is a point of sale that lives in a web page: it shows a Solana Pay QR, watches the chain and marks the sale paid. It never connects to a wallet, never asks for a signature and holds no key. This post shows the three pieces of code that make that a property of the design rather than a promise, and the 57 open checks that prove it.
1. Only three read requests, enforced in code
Every network call in the app goes through one function. It knows exactly three JSON-RPC methods, all of them reads:
const READ_ONLY = new Set(['getSignaturesForAddress', 'getTransaction', 'getAccountInfo']);
async function rpc(method, params) {
if (!READ_ONLY.has(method)) throw new Error('Blocked: the counter only reads the chain');
const r = await fetch(rpcUrl(), {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),
});
const j = await r.json();
if (j.error) throw new Error(j.error.message || 'RPC error');
return j.result;
}
There is no sendTransaction, no wallet adapter, no signTransaction. A static test reads the source and fails if any of those words appear, or if the allow-list ever holds a fourth method.
2. One reference key per sale
Each sale gets a fresh 32-byte reference, encoded in base58, and the Solana Pay URL carries it:
solana:<recipient>?amount=12.5&spl-token=<mint>&reference=<ref>&label=Rose%20Corner&memo=order%3Ak1%20%C2%B7%20SKU-42
The buyer's wallet adds the reference as a read-only account. The counter then asks getSignaturesForAddress(reference) until a signature appears. No server, no webhook: the reference is the order number the chain can index.
3. A payment counts only when five things match
Finding a signature is not enough. The counter loads the transaction with getTransaction (jsonParsed) and checks it with a pure function:
function verifyPayment(tx, { recipient, reference, splToken, expected }) {
const reasons = [];
if (!tx || !tx.meta || !tx.transaction) return { ok: false, reasons: ['Transaction not found'] };
if (tx.meta.err) reasons.push('Transaction failed on-chain');
const keys = tx.transaction.message.accountKeys.map((k) => (typeof k === 'string' ? k : k.pubkey));
if (!keys.includes(reference)) reasons.push('Reference key is not in the transaction');
let received = 0n;
if (splToken) {
const sum = (arr) => (arr || []).filter((b) => b.owner === recipient && b.mint === splToken)
.reduce((a, b) => a + BigInt(b.uiTokenAmount.amount), 0n);
received = sum(tx.meta.postTokenBalances) - sum(tx.meta.preTokenBalances);
} else {
const i = keys.indexOf(recipient);
if (i < 0) reasons.push('Recipient is not in the transaction');
else received = BigInt(tx.meta.postBalances[i]) - BigInt(tx.meta.preBalances[i]);
}
if (received < expected) reasons.push(`Received ${received} base units, expected ${expected}`);
return { ok: reasons.length === 0, received, reasons };
}
Reference, recipient, token, amount and success. A payment to another address, a smaller amount or a failed transaction is shown as "not valid", with the reason. Token decimals are read from the mint with getAccountInfo before the sale, so a wrong decimal setting cannot inflate an amount.
What a shop gets on top
-
Several wallets: wallet #1 plus #2..X, each with a type and a name (
#2 · Department · Toys,#3 · Tips · Bar tips). The payment is verified against the wallet chosen for that sale, and a head office view adds up sales per wallet. - A setup PIN: the owner of the device sets the receiving wallets, so nobody at the till can paste their own. The PIN is stored only as a salted SHA-256. Forgot it: reinstall, enter the wallets again, set a new PIN.
-
Comment, receipt, refund note, CSV: a product code travels as the memo where the buyer's wallet supports it (and a memo is public). The receipt is not a fiscal receipt. A refund is a new payment from the shop's own wallet with
refund:<original signature>in the memo.
57 checks you can rerun
node counter-core.test.js # 25 checks: base58, URLs, verification, savings, periods, memo, PIN format
node counter-safety.test.js # 13 checks by reading the code: no signing, no sending, 3 RPC methods, CSP, PIN
node browser-safety.e2e.js URL # 19 checks in a phone browser with fake wallets and hostile input
The browser test injects fake window.solana and friends that record any touch. They stay untouched. It feeds the page a hostile "signature", a hostile memo and a payment to the wrong address, and checks that none of them gets through. The safety test also prints one SHA-256 fingerprint for the whole block of files, so anyone can tell the original build from a changed one.
Found a way to make it sign, send or lie? That is exactly what the open audit is for: open an issue.
Devnet first. Example code, not audited. Educational content, not financial advice.
The counter, the solution page and the 57 checks (Apache-2.0):
https://wen-watt.github.io/lab/counter.html




Top comments (0)