settlePayment() function is called by all three transports (REST, A2A JSON-RPC middleware, and A2A Executor). It inspects your SellerConfig and routes to one of two settlement strategies: Facilitator Mode (the default) or Gas Wallet Mode.
Both strategies verify the client’s EIP-3009 transferWithAuthorization signature and then settle the USDC transfer on-chain. They differ in who broadcasts the transaction and who pays the gas.
Strategies
- Facilitator Mode
- Gas Wallet Mode
Facilitator mode is the default strategy. It delegates on-chain settlement to an external facilitator service (Coinbase CDP). Your server never touches a private key or pays gas.You can override it in your config:Required environment variables:
How It Works
POST {facilitatorUrl}/verify— sends theX402PaymentPayloadand payment requirements to the facilitator.- Check
isValidin the response. Iffalse, settlement is rejected. POST {facilitatorUrl}/settle— the facilitator broadcaststransferWithAuthorizationon-chain and returns the transaction hash.- Return
{ txHash, settleResponse, payer }to the engine for state transition.
transferWithAuthorization call on-chain. The client signs off-chain and never pays gas.Configuration
The default facilitator URL for both testnet and mainnet is:When to Use
- Production deployments where you want zero gas management overhead.
- The facilitator pays all transaction fees on Base.
- You only need Coinbase CDP API credentials.
Nonce Serialization
When using Gas Wallet Mode, concurrent settlement requests can cause nonce conflicts because all transactions originate from the same wallet address. Key0 prevents this with automatic nonce serialization.| Strategy | When | How |
|---|---|---|
| Redis distributed lock | config.redis is provided | SET NX with 60-second TTL. Lua-script atomic release. Poll interval: 200ms. Max wait: 30s (throws HTTP 503 on timeout). Lock key is scoped to the gas wallet address. |
| In-process queue | No Redis configured | Promise-based serial queue. Works for single-instance deployments only. |
Facilitator mode does not need nonce serialization because the facilitator service manages its own transaction ordering.
Comparison
| Facilitator (default) | Gas Wallet | |
|---|---|---|
| External dependency | Coinbase CDP | None |
| Gas costs | Facilitator pays | Your gas wallet pays ETH |
| Setup | CDP API keys (CDP_API_KEY_ID, CDP_API_KEY_SECRET) | Private key in environment (GAS_WALLET_PRIVATE_KEY) |
| Multi-replica | Works out of the box | Requires Redis for nonce serialization |
| Best for | Production — no gas management | Self-contained — no third party |

