x402 Deferred Payment Scheme
The deferred payment scheme is a payment scheme for x402 that was contributed by Edge & Node to support trust-minimized micro-payments. Unlike the exact scheme, which requires payments to be executed immediately and fully on-chain, the deferred scheme allows clients to issue signed vouchers (IOUs) off-chain, which can later be aggregated and redeemed by the seller.
Note: This scheme was proposed and implemented by Edge & Node in PR #426 to the x402 protocol repository. The PR introduces the deferred scheme specification to enable micro-payments that are smaller than the minimum feasible on-chain transaction cost.
Overview
The deferred scheme is designed to enable payments smaller than the minimum feasible on-chain transaction cost. By allowing off-chain voucher issuance with on-chain settlement, it makes micro-payments economically viable for both buyers and sellers.
Key Benefits
The deferred scheme enables:
- Micro-payments: Support payments smaller than the minimum feasible on-chain transaction cost
- Voucher aggregation: Multiple payments can accumulate on the same voucher ID before settlement
- Gas efficiency: Sellers can batch collections when it's economically viable to pay gas fees
- Trust-minimized: Uses escrow contracts to protect both parties without requiring immediate on-chain execution
How It Works
The following sequence diagram illustrates the complete flow of the deferred payment scheme, showing both the resource request phase and the payment settlement phase:
The deferred payment flow consists of four main steps:
1. Deposit
Buyer deposits funds into an escrow contract for a specific seller. This can be done via:
- Direct on-chain transfer
- Signed authorization (EIP-3009) that allows the escrow contract to pull funds
2. Voucher Issuance
For each payment, the buyer sends a signed voucher off-chain to the seller. Each voucher:
- Is cryptographically signed by the buyer
- Contains payment details (amount, recipient, etc.)
- Can be aggregated with other vouchers sharing the same voucher ID
3. Voucher Aggregation
Multiple payments can accumulate on the same voucher ID:
- Each new payment increases the total owed (
valueAggregate) on the same voucher - A nonce mechanism ensures sequential aggregation
- All vouchers are validated before aggregation to prevent double-spending
4. Collection
The seller collects accumulated vouchers on-chain when:
- The total amount is worth the gas cost
- A specific threshold is reached
- A predetermined time interval has passed
The collection process settles all aggregated vouchers in a single on-chain transaction, maximizing gas efficiency.
Comparison with Exact Scheme
| Feature | Exact Scheme | Deferred Scheme |
|---|---|---|
| Execution | Immediate on-chain | Off-chain vouchers, on-chain settlement |
| Payment Size | Suitable for larger amounts | Optimized for micro-payments |
| Gas Cost | Paid per transaction | Batched and optimized |
| Latency | Instant settlement | Delayed until collection |
| Use Case | Real-time payments | High-volume micro-payments |
Use Cases
The deferred scheme is particularly valuable for:
- Agent-to-Agent Payments: Where transaction volumes are high but individual amounts are small
- API Call Payments: Pay-per-use services where each call costs less than gas fees
- Subscription Services: Small recurring payments that can be aggregated
- Content Monetization: Micro-payments for content consumption
Technical Details
Voucher Structure
Each voucher contains:
voucherId: Unique identifier for the vouchernonce: Sequential number for aggregationvalueAggregate: Total accumulated valuesignature: Cryptographic signature from the buyer
Escrow Contract
The escrow contract provides:
- Per-buyer/seller/asset escrow accounts
- Thawing period for withdrawals (buyer protection)
- Automatic collection mechanisms
- Authorization-based funding (EIP-3009)
Security Considerations
- Nonce validation: Ensures sequential voucher aggregation
- Signature verification: Prevents unauthorized voucher creation
- Escrow protection: Funds are locked until collection
- Thawing mechanism: Protects buyers from sudden seller withdrawals