Developers
Architecture
One Next.js app, one worker, one Postgres, one escrow on QIE. Every way in, from the website to an AI chat, goes through the same order service.


| Part | What it is | What it does |
|---|---|---|
| Web app | Next.js 16 (React 19, wagmi 3, viem, TanStack Query) | Pay screens, receipts, the scorecard, the docs, the HTTP API and the MCP endpoint. Signs prices with the quote key, which can't move money |
| Worker | The same code bundled for Node, pg-boss jobs | Reads every escrow event, buys bills, asks providers again, releases and refunds, pays rewards, publishes the rate, sends Telegram notices |
| Postgres | Drizzle | Orders and their events, deliveries, chain events with the indexer's cursor, jobs. Phone, meter and smartcard numbers are encrypted |
| TodokuEscrow | Solidity, on QIE mainnet at 0x2a2f…E2a5 (production) and 0xff54…a783 (staging), verified | Holds each payment until release, refund or reclaim |
| FiatRateFeed | Solidity, on QIE mainnet at 0xd978…934a, verified | Todoku's naira rate, public once deployed |
One order service
The website, shops, bulk sales, pay links, the demo line and the MCP endpoint all price through one function; drops are priced by their own pot quote: the switches and the daily cap at funding, the switches and the provider float at each claim. Every price runs the same checks: kill switches, the provider's float, the per-order and daily caps, the duplicate and in-flight guard, the rate snapshot, the QIEDEX quote, then the EIP-712 signature. The prices, limits and rewards tier in force are stored on the order.
Moving money safely
- Chain events decide. Only an escrow event moves an order into Held, Released, Refunded or Reclaimed. When the app says "I paid", the web app reads that transaction's receipt and applies its escrow events at once; the indexer sees them again later.
- Every state change is guarded twice:
UPDATE … WHERE status = fromin code, and a database trigger with the allowed-transition table. - The provider's answer decides delivery. Webhooks only trigger a fresh question to the provider.
- Every transaction is stored before it is sent, one signer at a time, and re-sent after a crash.