Overview
The escrow scheme for x402 v2 leverages the Base Commerce Payments Protocol to enable secure, conditional fund handling using the auth/capture pattern.This proposal is based on Agentokratia’s escrow proposal (#834) and extends it to support arbitrary operator implementations using audited on-chain escrow contracts.
Auth/Capture Pattern
The escrow scheme provides four primitives:Authorize
Lock funds in escrow at request time. Client signs ERC-3009 authorization, facilitator calls
escrow.authorize() to pull tokens into escrow contract.Capture
Release earned amount to receiver. Operator calls
escrow.release() based on configured conditions (time elapsed, work verified, etc.).Void
Return unused funds to payer. Operator calls
escrow.void() for full refunds during escrow period.Visual Flow
Exact Payment (Immediate Settlement)
Escrow Payment (Deferred Settlement)
Key Differences
| Aspect | Exact | Escrow |
|---|---|---|
| Settlement | Immediate on request | Deferred until conditions met |
| Payer Protection | None (payment final) | Refundable until capture |
| Resource Delivery | After payment clears | Immediately after authorization |
| Recourse | No recourse | Can reclaim after expiry |
| Use Case | Trusted, low-value, instant | High-value, variable cost, disputes |
Operator Flexibility
The operator is the key abstraction. Different implementations enable different payment patterns:| Use Case | Operator Behavior |
|---|---|
| Session billing | Track usage off-chain, capture periodically |
| Time-locked escrow | Release after period expires |
| Dispute resolution | Arbiter decides release vs refund |
| Immediate (exact-like) | Use charge() for instant settlement |
| Streaming payments | Time-proportional captures |
Message Format
PaymentRequired (402 Response)
Server sends this to request payment:PaymentPayload (Client Response)
Client sends this with signed authorization:Field Reference
Required Extra Fields
| Field | Type | Description |
|---|---|---|
escrowAddress | address | AuthCaptureEscrow contract address on the specified network |
operatorAddress | address | Address with capture/void authority (stored in PaymentInfo.operator) |
tokenCollector | address | ERC-3009/Permit2 token collector contract address |
Optional Extra Fields
| Field | Type | Description | Default |
|---|---|---|---|
authorizeAddress | address | Where facilitator calls authorize() | operatorAddress if operator is a contract, escrowAddress if operator is an EOA |
minDeposit | uint256 | Minimum accepted deposit amount (wei) | No minimum |
maxDeposit | uint256 | Maximum accepted deposit amount (wei) | No maximum |
authorizationExpirySeconds | uint32 | Seconds until payer can reclaim funds | type(uint32).max (effectively never) |
refundExpirySeconds | uint48 | Seconds until refunds are no longer allowed | type(uint48).max (effectively never) |
minFeeBps | uint16 | Minimum fee in basis points | 0 |
maxFeeBps | uint16 | Maximum fee in basis points | 0 |
feeReceiver | address | Address receiving fees | operatorAddress |
Fee Configuration: Fees are enforced on-chain in the PaymentInfo struct. The operator contract cannot charge more than
maxFeeBps or less than minFeeBps.Authorization vs Capture
Understanding the two-phase process:Phase 1: Authorization (HTTP Request)
Phase 2: Capture (After Work)
Safety Guarantees
The escrow contract enforces invariants on-chain:No Overcharging
Operator cannot capture more than authorized
maxAmount. Attempting to exceed the limit reverts the transaction.No Double-Spend
Funds are locked at authorization. Payer cannot use the same tokens elsewhere until void/reclaim.
Payer Reclaim
If
authorizationExpiry is set, payer can reclaim funds after expiry without operator approval.Fee Bounds
Min/max fee bounds in PaymentInfo are enforced on-chain. Operator must respect these limits.
Sequence Diagram
vs Exact Scheme
Theescrow scheme adds an authorization step before settlement. For simple immediate payments where trust is not a concern, the exact scheme remains more efficient.
See Comparison for detailed trade-offs.
Next Steps
Overview
Understand why escrow is needed for HTTP payments.
Comparison
Compare escrow vs exact schemes in detail.
Smart Contracts
Learn about escrow and operator contracts.
SDK Installation
Build your first escrow-based payment flow.
