The escrow contract
TodokuEscrow holds every payment in QUSDC. What it owes can go only to Todoku's treasury after delivery, the payer, or a drop's funder, and it can't be upgraded.
TodokuEscrow (Solidity 0.8.28, OpenZeppelin 5.6.1) is the promise in code. It is not upgradeable: no proxy, no admin who can swap the logic. Money it owes can leave to three places only: Todoku's treasury, the wallet that paid, or a drop's funder; the admin can sweep only the surplus above what it owes.
| Contract | What it does | Address |
|---|---|---|
| TodokuEscrow | Holds every payment until delivery, refund or reclaim | Reading this deployment… |
| FiatRateFeed (NGN / USD) | Todoku's naira rate, published on QIE | Reading this deployment… |
What each function does
| Function | Who may call it | Works while paused? | What it does |
|---|---|---|---|
payWithQIE(quote, sig) | The payer named in the quote | No | Opens the orders as Held, swaps the QIE sent for the exact QUSDC on QIEDEX, returns leftover QIE |
payWithQUSDC(quote, sig) | The payer | No | Opens the orders and pulls the exact QUSDC (approve first) |
release(orderId) | Todoku's operator | No | Held → Released: the QUSDC goes to the treasury |
refund(orderId, reason) | Todoku's operator | Yes | Held → Refunded: back to the payer, or into the drop's pot while it runs |
reclaim(orderId) | Only the payer | Yes | After RECLAIM_DELAY: Held → Reclaimed, back to the payer |
fundPotWithQIE / fundPotWithQUSDC | The funder in the pot quote | No | Funds or tops up a drop's pot |
claimFromPot(potId, orderId) | Todoku's operator | No | Turns one claim into a Held order paid from the pot |
reclaimPot(potId) | Anyone | Yes | After the drop ends: what's left goes to the funder |
pause / unpause | Pauser / admin | Stops new payments and releases; refunds and reclaims keep working | |
sweepExcess(to) | Admin | Moves only what the contract holds beyond what it owes |
The checks on every payment
Todoku signs each price with EIP-712 (Quote(payer, orderIds[], amounts[], expiry), domain "TodokuEscrow", version 1). The contract refuses a payment when:
- the caller isn't the payer in the quote, or the quote expired;
- the signature isn't Todoku's quote key;
- an order id was used before;
- one order is over 100 QUSDC, a payment over 2,000 QUSDC or 20 lines;
- the QUSDC that arrived isn't exactly the total.
Every order sits in one storage slot: payer, amount, paid time and status (None, Held, Released, Refunded, Reclaimed). Each one moves from Held to exactly one ending.
Reclaim
RECLAIM_DELAY is fixed when the contract is deployed: never under 10 minutes; planned at 24 hours for production, and 10 minutes on the test build. The app reads it from the contract, so the order page always shows the real time.
Tested
39 Foundry tests: 25 unit tests, 4 invariants (the balance always covers what is owed; what is owed equals held orders plus pot balances; money in equals money out plus the balance; no QIE left in the contract), 4 for the rate feed, 2 on a QIE mainnet fork (pay in QIE, release; pay in QUSDC, refund on the real router, WQIE and QUSDC), and 4 for the test-chain stand-ins.
Events and the full ABI: Escrow events.