Skip to content
Skip to Content
Developers

Escrow events

Every order's life on QIE as events you can index yourself. Ids and amounts only, never a phone number, meter or name.

Anyone can follow Todoku on the explorer or index the escrow. Order and pot ids are 32 random bytes; nothing personal goes on chain.

EventFields (indexed marked)
OrderPaidbytes32 indexed orderId, address indexed payer, uint256 amount, uint8 asset
PaymentReceivedaddress indexed payer, uint8 asset, uint256 totalQusdc, uint256 qieSpent
OrderReleasedbytes32 indexed orderId, uint256 amount
OrderRefundedbytes32 indexed orderId, address indexed to, uint256 amount, uint8 reason
OrderRefundedToPotbytes32 indexed orderId, bytes32 indexed potId, uint256 amount, uint8 reason
OrderReclaimedbytes32 indexed orderId, address indexed to, uint256 amount
PotFundedbytes32 indexed potId, address indexed funder, uint256 amount, uint256 endsAt, uint8 asset
PotOrderCreatedbytes32 indexed potId, bytes32 indexed orderId, uint256 amount
PotReclaimedbytes32 indexed potId, address indexed funder, uint256 amount
TreasuryUpdated, QuoteSignerUpdated, LimitsUpdated, ExcessSweptAdmin changes

Amounts are QUSDC with 6 decimals. asset is 0 for QUSDC, 1 for QIE. Refund reasons are listed on the status map.

Read an order

watch-escrow.ts
import { createPublicClient, http, parseAbiItem } from "viem";

const escrow = "0x…"; // TodokuEscrow, see QIE → Addresses
const client = createPublicClient({ transport: http("https://rpc5mainnet.qie.digital") });

// Status: 0 None, 1 Held, 2 Released, 3 Refunded, 4 Reclaimed
const order = await client.readContract({
  address: escrow,
  abi: [parseAbiItem("function getOrder(bytes32) view returns ((address payer, uint56 amount, uint32 paidAt, uint8 status))")],
  functionName: "getOrder",
  args: ["0x…orderId"],
});

// Every release in a block range (QIE nodes answer up to 10,000 blocks per call)
const released = await client.getLogs({
  address: escrow,
  event: parseAbiItem("event OrderReleased(bytes32 indexed orderId, uint256 amount)"),
  fromBlock: 0n,
  toBlock: 9_000n,
});

solvency() returns the escrow's QUSDC balance and what it owes (held orders plus pot balances); the contract never pays out below what it owes (tested as an invariant); only an outside QUSDC burn could break that (see Risks).

The price signature

Todoku's quote key signs, and the contract checks, this EIP-712 message:

Domain:   name "TodokuEscrow", version "1", chainId 1990, verifyingContract = the escrow
Quote:    Quote(address payer, bytes32[] orderIds, uint256[] amounts, uint256 expiry)
PotQuote: PotQuote(bytes32 potId, address funder, uint256 amount, uint256 perClaim, uint256 endsAt, uint256 expiry)

Drop claims are signed by the claimer, off chain, and checked by Todoku: domain { name: "Todoku", version: "1", chainId }, DropClaim(string drop, string phone, address wallet, uint256 issuedAt), valid for 10 minutes.

On this page