Skip to content
Skip to Content
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.

System: payers, shops and AI apps reach the Todoku web app and MCP endpoint; the worker releases and refunds on the escrow, buys bills from VTpass and publishes the rate feed; the escrow swaps on QIEDEX for QUSDC
Solid lines are the main paths: orders, payments, settlement, the database and rate publishing. Dotted lines are the Paycrest rate, Telegram notices and the switched-off Fonbnk route. The escrow and the feed run on QIE mainnet ([Addresses](/docs/qie/addresses)).
PartWhat it isWhat it does
Web appNext.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
WorkerThe same code bundled for Node, pg-boss jobsReads every escrow event, buys bills, asks providers again, releases and refunds, pays rewards, publishes the rate, sends Telegram notices
PostgresDrizzleOrders and their events, deliveries, chain events with the indexer's cursor, jobs. Phone, meter and smartcard numbers are encrypted
TodokuEscrowSolidity, on QIE mainnet at 0x2a2f…E2a5 (production) and 0xff54…a783 (staging), verifiedHolds each payment until release, refund or reclaim
FiatRateFeedSolidity, on QIE mainnet at 0xd978…934a, verifiedTodoku'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 = from in 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.

On this page