Outcome: a ranked candidate chosen, preflighted, signed, and settled.Time: 10-15 minutes end to end.Bring: EVM wallet basics, token-approval familiarity, and an API key (
tfk_test_ hits the sandbox).Router vs RFQ at a Glance
The RFQ API returns only firm solver/LP quotes backed by the escrow’s delivery-or-refund guarantee. The Router API casts a wider net - it fans your request across every eligible execution source and hands back ranked candidates, each stating its own guarantees.Step 1 - Ask for Candidates
Useful optional fields:
Delivery is addressable: the input’s
user funds and signs, while every output pays out to its own receiver - which can be any wallet you name, under either execution mode.ExactInput or ExactOutput?
ExactInput or ExactOutput?
ExactInputwhen the amount you’re sending is fixed - “swap 25 USDC, get whatever that buys”ExactOutputwhen the amount you need is fixed - “I need exactly 20 USDC on Base, charge me what it takes”
Reading the Candidate List
The response is a ranked list - every entry is executable, and the aggregation metadata tells you how the sweep went:order payload you sign, and settle natively via apiSubmit. Composite candidates (like the second) are planner-assembled multi-leg routes - their composite block describes the legs, and they typically execute via walletBroadcast with prepared transactions from preflight:
Step 2 - Preflight the One You Picked
nextActions - an ordered execution plan telling you exactly what to do: approvals to mine, payloads to sign, where to submit.
type (evmTransaction, signTypedData, postOrder, …), purpose (tokenApproval, orderSignature, orderSubmit, …), and actor - userWallet means your side signs or broadcasts; tetrafiApi means it goes through the API with your key. Token-approval actions arrive as ready-to-broadcast transactions; see Token Approvals for the full treatment.
Step 3 - Sign and Send
How the trade lands depends on the candidate’s execution mode - preflight already told you which path you’re on:- apiSubmit (native settlement)
- walletBroadcast (self-execution)
The Sign exactly the typed data preflight returns - the
signTypedData action carries the EIP-712 payload; sign it verbatim and submit where submitTo points. TetraFi puts the settlement on-chain.integrityChecksum rejects any drift between what you were shown and what you submit. Use an Idempotency-Key header so a retried POST can’t double-submit.Submission fields:escrow-v0 payload reference
escrow-v0 payload reference
The
order field on a candidate (and the typedData on preflight’s orderSignature action) is a complete EIP-712 envelope - domain, types, and a StandardOrder message covering:You never assemble this payload yourself - sign the structure exactly as returned. Any field you’d want to change (receiver, amount, expiry) changes at quote time, not signing time.
Funding Lock Variants
The escrow can pull your input three ways; preflight picks whichever the corridor and token support, so your code stays the same:- Permit2 - one reusable approval of the Permit2 contract, then each order authorizes its pull inside the signature.
- EIP-3009 - USDC-style tokens authorize the transfer entirely inside the signed message; no approval transaction ever.
- Resource lock - pre-deposited balance in the compact settler, drawn per order.
Step 4 - Watch It Settle
Poll the order, or subscribe over WebSocket for push updates:wss://api.tetrafi.io/api/v1/ws?token=<key> and subscribe to the orders:{orderId} topic:
The order record carries more than the bare status:
Because settlement is delivery-versus-payment, a failure is never a loss: if delivery can’t be proven before expiry, the escrow refunds the input.
Full Example
- apiSubmit
- walletBroadcast
Keep Building
Token Approvals
The approval loop, lock types, and reusable setup.
RFQ API Quickstart
The firm-quote path, when escrow guarantees matter most.