x402r uses a fork of commerce-payments that adds partial void support for handling partially completed orders and partial refunds.
AuthCaptureEscrow
Core escrow contract for holding ERC-20 tokens during the payment lifecycle.- Type: Singleton (one per network)
- Access: Operator-based (only registered operators can manage payments)
- Address:
0xe050bB89eD43BB02d71343063824614A7fb80B77(all chains)
Payment State Machine
Key Methods
authorize()
Locks tokens in escrow. Called by operator.amount of token
The base escrow contract uses individual parameters (paymentId, payer, receiver, etc.) while the PaymentOperator wraps them in a
PaymentInfo struct. The operator translates between the two formats internally.release()
Releases tokens to receiver. Called by operator.InEscrow -> Released
void()
Returns tokens to payer (full refund). Called by operator.InEscrow -> Settled
reclaim()
Takes tokens back from receiver to give to payer. Called by operator.Released -> Settled
Requires: Receiver has approved escrow for amount
partialVoid()
Returns partial amount to payer (x402r addition).Security Features
- Operator whitelist - Only registered operators can manage payments
- Reentrancy protection - All state changes protected
- Event logging - Complete audit trail
ERC3009PaymentCollector
Collects ERC-20 tokens into escrow using the client’s off-chain ERC-3009 signature. The payer never submits a transaction.- Type: Singleton (one per network)
- Address:
0xcE66Ab399EDA513BD12760b6427C87D6602344a7(all chains)
How It Works
The operator calls the token collector duringauthorize() or charge(), passing the client’s signature as collectorData. The collector executes receiveWithAuthorization (ERC-3009) to pull tokens from the payer into escrow.
Features
- ERC-3009
receiveWithAuthorization()- Gasless token transfers via signed messages - EIP-6492 support - Handles smart wallet clients with deployment bytecode in signatures
- Nonce-based replay protection - Each authorization can only be used once
- Deadline-based expiry -
validBeforetimestamp prevents stale authorizations
ERC-3009 Signature
The client signs an EIP-712 typed data message with primary typeReceiveWithAuthorization:
The escrow scheme uses
receiveWithAuthorization (not transferWithAuthorization). The token collector is the to address, which then routes tokens to the escrow contract.