Escrow-Secured Checkout

On-chain escrow for humans and autonomous agents

Explore the escrow lifecycle with simulated settlement, signed USDC authorization, and programmable release logic.

payment.ts
import { escrowFetch } from "x402-escrow";
 
const { payment } = await escrowFetch(
"https://merchant.xyz/api/order/981/pay",
{ method: "POST", body: JSON.stringify(order) },
{ walletClient }
);
 
// payment.escrowId + payment.txHash
Buyer Gas Cost
$0
Settlement
Simulated
Escrow Visibility
Realtime
Authorization
EIP-712
Asset
USDC

End-to-End Escrow Settlement Flow

1RequestClient sends HTTP request
402402Server returns Payment Required
3SignClient signs EIP-712 authorization
4RetryClient retries with X-PAYMENT
5EscrowFunds locked in smart contract
6DeliverSeller confirms delivery
7ReleaseFunds released to seller

Sequence: payment negotiation, typed-data signature, and escrow settlement all visible in the protocol inspector.

How It Works

Three layers working together: client SDK, server middleware, and smart contract.

TypeScript
// Automatic escrow payment flow
const { payment } = await escrowFetch(
"https://api.example.com/order/123/pay",
{ method: "POST" },
{ walletClient }
);
// payment.txHash — on-chain escrow
// payment.escrowId — escrow ID

On-Chain Reputation System

Every escrow outcome builds a permissionless credit score that shapes future transaction terms.

Score Formula

Completion Rate40–45%
Non-Dispute Rate25%
Non-Refund / Non-Frivolous15–20%
Volume Bonus10%

Computed from on-chain stats. Seller and buyer formulas weight factors differently.

Confidence Levels

Low

< 3 escrows

Default parameters, score not shown

Medium

3–9 escrows

Score visible, history building

High

10+ escrows

Full parameter adjustments active

Dynamic Release Windows

High trust (score ≥ 80, high confidence)Shortened
New or moderate trustDefault
Low trust (score < 40)Extended

High-trust pairs settle faster. New or risky counterparties get more protection time.

x402Escrow

Agentic payments with simulated escrow state for offline demos.

Mock Chain (Simulated)

Simulation

Mock mode uses an in-memory escrow store and generated tx hashes.

No live contract interactions are broadcast.

Resources

External chain links are hidden in simulation mode.

x402 Escrow Protocol · Mock Chain Mode · Events and tx hashes are simulated