# Accept Nano payments without a processor: implementation spec

Follow these steps in order. Each step ends with a check. Stop and ask the site owner when a step says "ask".

- Guide: https://nano133.com/guides/accept-nano-payments · as Markdown: https://nano133.com/guides/accept-nano-payments.md
- Stage: **Alpha**. We ran its code and its checks pass. It read a real node (read only), or, if it needs no node, it ran on real signatures or real files. Where it copies code that nano133.com runs, a test shows both act the same. Last checked 2026-10-24.
- Tracks (use the one the owner runs; tell the owner when it is Pre-alpha): gcp (Pre-alpha), cloudflare (Pre-alpha)
- Use at your own risk, for education. Real Nano moves: keep amounts small.
- Code files: https://nano133.com/guides/accept-nano-payments/code/edge-state.mjs · https://nano133.com/guides/accept-nano-payments/code/accept-nano.mjs

## Rules that must hold

1. Never change the secret or the label after money has come in. Take each index from an atomic counter that never goes down, and refuse an index of 1,000,000 or more. The secret stays on the server: never log it, return it, store it in a database, or put it in a page, a repository or a message. The same goes for a seed and a private key.
2. Work in raw with big integers, never with floating point. Round the price up to a whole 0.0001 XNO, and refuse a price below it. The price comes from your server, never from the browser.
3. Build the QR code and the wallet link from the address and the quote that your server returned. Show every digit of the amount. Never round it on the screen.
4. Credit a payment only when its block is a confirmed send to this checkout's address of exactly the quote, first seen inside the window. There is no tolerance: one raw more or less is not this checkout's payment.
5. Record the block hash as used and mark the checkout paid in one transaction. Refuse a hash that is already used.
6. The destination of the sweep is a value in your code or your deploy settings, never a field of a request or a row. Stop when a record is wrong. Receive only the paid block. Record the signed send before you publish it, and let one run hold the checkout. Run the sweep from a timer, never from a visitor's request.
7. When your node does not answer, credit nothing and answer busy (HTTP 503). Never use a node that you do not trust for this decision. Send every other payment back in full. Rate-limit the checkout and claim routes for each visitor.
8. Never change IAM, Secret Manager or the Cloud Run service yourself, and never let a coding agent do it: the owner grants the access and maps the secret. Map a pinned version, never `latest`.
9. The secret goes in with `wrangler secret put`, never in `vars`, in the configuration file, in the repository or in a log. Never run `wrangler deploy` or change an account for the owner.
10. Run the sweep and the returns only from the timer, and let one run hold the lock. Do not call a node from a request just to sweep.

## Steps

The guide has the how for each step. This list has what must be true at its end.

1. **Give each checkout its own address.** Check: run the example with `--address 0` twice: the same address both times. Run it with `--address 1`: a different address.
2. **Turn the price into a clean quote.** Check: a price of 0.0271 XNO gives `27100000000000000000000000000` raw. A price of 0.00001 XNO is refused.
3. **Show the payment.** Check: scan the QR code with a wallet: it opens with the checkout's own address and the exact amount filled in.
4. **Find the payment.** Check: run the example below with `--check` on a send you already received (its block hash, the address it went to and its amount in raw): it answers `paid`.
5. **Check that it really pays this checkout.** Check: the same block checked against a different amount answers `another amount`, and against another address answers `sent to another address`. Neither answers `paid`.
6. **Credit it once.** Check: send the same claim twice at the same moment: your database records the block hash once and marks the checkout paid once.
7. **Move the money to your wallet: the sweep.** Check: pay a test checkout and run the sweep: the checkout's address makes one send of exactly the quote to your wallet. Run it again: it says there is nothing to send.
8. **Send anything else back, and fail closed.** Check: stop your node and claim: the page says “try again”, and nothing is credited.

## Done when

- [ ] Step 1 check passes.
- [ ] Step 2 check passes.
- [ ] Step 3 check passes.
- [ ] Step 4 check passes.
- [ ] Step 5 check passes.
- [ ] Step 6 check passes.
- [ ] Step 7 check passes.
- [ ] Step 8 check passes.
- [ ] `node test.mjs` passes in mock mode (put the code files next to it). It never sends money.
- [ ] You told the owner the stage of this guide and of the track you used.

## What breaks, and what it costs

| Failure | Loss in Nano | Check |
| --- | --- | --- |
| The secret leaks | Everything that waits at every checkout address, and every address made later | Steps 1 and 7: the secret stays on the server, in a secret manager, and the sweep keeps little at an address |
| The secret or its label changes after money came in | The money stays at the older addresses. Only the old secret and label sweep or return it | Step 1: never change either once money has come in |
| A wallet cuts or rounds the amount (a tail, in the keyless way) | The buyer pays and gets nothing until the money goes back | Step 2: a clean quote with no tail. Step 8: send any other amount back in full |
| A block is credited twice | One block pays two checkouts, or one checkout twice | Step 6: record the block hash and mark the checkout paid in one transaction |
| The sweep runs twice, or crashes after the send | A second send of the same payment | Step 7: record the signed send before you publish it, and let one run hold the checkout |
| The sweep reads its destination from a request or a row | The money goes to an address that a visitor chose | Step 7: the destination is fixed in your code |
| Your node does not answer | A wrong credit, if you do not fail closed | Step 8: answer “busy” and credit nothing |

## Notes for agents

Ask the site owner for these four things before you start. Never guess them:

1. The wallet address that the sweep sends to. It goes in code or in deploy settings. It is never read from a checkout, a request or a database row.
2. The RPC address of their own Nano node, and the confirmation that it allows `receivable`, `block_info`, `account_info`, `work_generate` and `process`.
3. Where the 32-byte secret lives. It is in their secret manager. It is never in the repository, the database, a page or a log.
4. The database for the index counter, the checkouts and the used block hashes, and that it has transactions.

The secret and its label never change once money has come in. The counter never goes down. Test with a tiny amount first.

For a platform, ask which one the owner runs (Google Cloud or Cloudflare Workers) and use that track. Both tracks are Pre-alpha: say so to the owner. Never run `gcloud` or `wrangler`, and never change IAM, a secret, a service or an account yourself: tell the owner what to run and let them run it. The owner maps the secret as a pinned version (Google Cloud) or with `wrangler secret put` (Cloudflare), and writes the schedule of the timer.
