Skip to main content
x402Escrow Deploy
Prerequisites:
Foundry installed
Git installed

Clone and Build

Run Tests

All 43 tests should pass, covering initialization, settlement, release, refunds, role management, upgrades, and edge cases.

Check Gas Usage

Compares current gas usage against the committed baseline in .gas-snapshot.

Supported Networks

Environment Setup

.gitignore excludes .env from commits. Never commit .env to version control.

Deploy

The deployment script deploys two contracts:
  1. x402Escrow implementation — the contract logic.
  2. ERC1967Proxy — the proxy that delegates to the implementation and holds all state.
Start a local node:
In a new terminal:
The script outputs both the implementation and proxy addresses. Use the proxy address for all interactions.

Post-Deployment Verification

If deployed with --verify, the source code appears on Basescan. Otherwise, verify manually:

Role Management

Add a Facilitator

Remove a Facilitator

Adjust Timeout

Valid range: 300 (5 minutes) to 86400 (24 hours).

Upgrade Procedure

x402Escrow uses the UUPS proxy pattern. To upgrade:
  1. Deploy the new implementation contract.
  2. Call upgradeToAndCall() on the proxy from the Owner address.
When deploying your contract, maintain storage layout compatibility. Do not reorder or remove existing state variables.

Production Checklist

  • Deploy with a hardware wallet or multisig as the Owner
  • Use separate addresses for Owner, Admin, and Facilitator roles
  • Verify contract source on block explorer
  • Confirm USDC address is correct for the target network
  • Confirm timeoutSecs is appropriate for your use case
  • Set up event monitoring for Deposited, Released, and Refunded
  • Test a full escrow cycle (settle -> release) on testnet before mainnet
  • Ensure .env is listed in .gitignore