Truce

Invoices a buyer can verify before paying, then pay gaslessly in USDT on Whitechain.

Truce

Created At

ETHGlobal Mumbai

Project Description

Truce stops invoice payment-redirection fraud: an attacker copies a real invoice, swaps in their own wallet, and the buyer pays the wrong address.

A merchant publishes one small file on its own domain, /.well-known/truce.json, listing the wallet that signs its invoices and the wallet that gets paid. Every invoice is an EIP-712 signature over the amount, payout wallet, due date and domain.

Before paying, the buyer's page runs ten checks against that domain file and shows PASS or FAIL. Change the amount, swap the payout wallet or point to a lookalike domain, and the invoice fails and Pay is disabled. The browser also remembers a merchant's wallets and warns if they change since the last payment.

On PASS the buyer signs one EIP-3009 receiveWithAuthorization for USDT: no approval and no gas. A relayer submits it and pays the WBT fee. Our InvoiceSettler contract verifies the merchant's signature again on chain, pays only the signed payout wallet, and settles each invoice once. A swapped payout reverts even if someone bypasses the app.

Merchants get a dashboard (create, status, CSV export), a 10-line SDK for their own app, optional pay-on-due-date with a pre-due balance check, and capped refunds.

Live on Whitechain Sepolia testnet with test USDT. Example merchants are fictional. A signed authorization is a commitment, not locked funds.

How it's Made

Contract: InvoiceSettler, written from scratch in Solidity with Foundry (49 tests), deployed and verified on Whitechain Sepolia (chain 1874) at 0xCbe41B98D2333a1BD92d51Fbb6FE668c5170ff9d. It recomputes the EIP-712 invoice hash, checks the merchant signature, then calls USDT's receiveWithAuthorization with itself as the recipient (the token requires msg.sender == to) and forwards the funds to the signed payout wallet only. A settled-once map blocks replays; refunds are capped at the amount paid.

Whitechain specifics: we reconstructed the track USDT's EIP-712 domain ("Tether USD", version "1", chain 1874, the proxy address) and matched it against the on-chain DOMAIN_SEPARATOR before writing any code, then ran a live gate test: redeem, replay rejection, wrong-payee rejection, time-window rejection and a signed cancel. 1-second blocks make settlement feel instant. Gas is paid in WBT by our relayer, so buyers need only USDT.

Real settlement: tx 0x837bdd3c07787486124245c2adb5d49c446f9243d292252c309ea82d1294fc22 (settle, block 12404546).

Shared TypeScript library (invoice-lib, 74 tests) for signing and the ten verification checks, used by both the browser and the server. Server: Node/Fastify REST API, viem relayer with simulation before sending, a daily gas budget, an RPC fallback, a due-date scheduler, and an SSRF-guarded fetch of the merchant's domain file (205 tests). Frontend: Vite + React + TypeScript, EIP-6963 wallet discovery, signing through MetaMask (106 tests). SDK: createInvoice() for merchant apps, with an example app.

Hacky bits: a payment link can carry the whole signed invoice in its URL fragment, so the verify page works without our server storing anything. The Soul (WhiteBIT KYC) badge is mocked and labelled as such, because the registry isn't readable on testnet yet.


background image mobile

Join the mailing list

Get the latest news and updates

Truce | ETHGlobal