# Escrow events (/docs/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.

| Event | Fields (`indexed` marked) |
| --- | --- |
| `OrderPaid` | `bytes32 indexed orderId, address indexed payer, uint256 amount, uint8 asset` |
| `PaymentReceived` | `address indexed payer, uint8 asset, uint256 totalQusdc, uint256 qieSpent` |
| `OrderReleased` | `bytes32 indexed orderId, uint256 amount` |
| `OrderRefunded` | `bytes32 indexed orderId, address indexed to, uint256 amount, uint8 reason` |
| `OrderRefundedToPot` | `bytes32 indexed orderId, bytes32 indexed potId, uint256 amount, uint8 reason` |
| `OrderReclaimed` | `bytes32 indexed orderId, address indexed to, uint256 amount` |
| `PotFunded` | `bytes32 indexed potId, address indexed funder, uint256 amount, uint256 endsAt, uint8 asset` |
| `PotOrderCreated` | `bytes32 indexed potId, bytes32 indexed orderId, uint256 amount` |
| `PotReclaimed` | `bytes32 indexed potId, address indexed funder, uint256 amount` |
| `TreasuryUpdated`, `QuoteSignerUpdated`, `LimitsUpdated`, `ExcessSwept` | Admin changes |

Amounts are QUSDC with 6 decimals. `asset` is 0 for QUSDC, 1 for QIE. Refund reasons are listed on the [status map](/docs/developers/status-map#refund-reasons-on-chain).

## Read an order [#read-an-order]

```ts title="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](/docs/trust/risks)).

## The price signature [#the-price-signature]

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

```text
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.