DEV Community

Lodestone
Lodestone

Posted on Edited on

I built a USDC checkout with no payment processor, ~400 lines of Python stdlib

Most "accept crypto" options either want KYC or take a cut. For a small digital shop I wanted neither, so here's the design:

1. A unique amount per checkout. A 15 USDC product becomes 15.000437 USDC. The 1–999 micro-unit suffix is the order ID, so there are no accounts, no memo fields and no per-order wallets.

2. Watch the chain with eth_getLogs. Poll the USDC contract on Base for Transfer(from, to=shop, value) logs every few seconds, using a couple of public RPCs as fallbacks (some don't serve getLogs). When a log value matches a pending session, mark it paid.

3. Tx-hash fallback. If the poller misses it, the buyer pastes the hash and the server checks the receipt directly.

4. HMAC download tokens. A paid session gets a 24h signed link. SQLite holds the sessions. Nothing else.

5. Discounts without double-dipping. A code's uses are counted only from paid sessions, server-side, and the discount is baked into the unique amount.

6. Optional emailed receipt. The buyer can enter an email. It's used once for the link and receipt, then nulled in the DB.

Gotchas: public RPC getLogs limits, 6-decimal USDC, race conditions on limited codes, and QR codes (EIP-681 ethereum:<token>@8453/transfer?address=…&uint256=…).

It now runs Lodestone, a Minecraft modpack shop with packs for every play style, from the free Boost performance pack to Hearth, Ironclad, Campfire, Donut PvP and Duel: https://jackiscool.com/shop/. Grab Boost for free, or buy a paid pack to watch the USDC checkout work.

Top comments (0)