@x402/* package layout.
For Go, Python, and full upstream details, see the
official migration guide.
Overview
| Aspect | V1 | V2 |
|---|---|---|
| Payment header | X-PAYMENT | PAYMENT-SIGNATURE |
| Response header | X-PAYMENT-RESPONSE | PAYMENT-RESPONSE |
| Network format | String (polygon-amoy, polygon) | CAIP-2 (eip155:80002, eip155:137) |
| Version field | x402Version: 1 | x402Version: 2 |
| Packages | x402-fetch, x402-axios, x402-express | @x402/fetch, @x402/axios, @x402/express, @x402/core, @x402/evm |
For buyers
Before (V1)
After (V2)
Key changes
- Package rename:
x402-fetch→@x402/fetch - Wallet setup: Use
x402Clientwith.register()instead of passing a chain-boundwalletClient - Environment variable:
PRIVATE_KEY→EVM_PRIVATE_KEY - Receipt header: Read
PAYMENT-RESPONSEviax402HTTPClient.getPaymentSettleResponse(), notdecodeXPaymentResponse()onx-payment-response
For sellers
Before (V1)
After (V2)
Key changes
- Package rename:
x402-express→@x402/express - Configuration structure: Route config uses an
acceptsarray with explicitscheme,network, andpayTo - Network format:
polygon-amoy→eip155:80002,polygon→eip155:137 - Resource server: Create
x402ResourceServerwith a facilitator client and register schemes with.register() - Middleware signature: Pass
(routes, server)instead of(wallet, routes, facilitatorConfig)
Network identifier mapping
| V1 name | V2 CAIP-2 ID | Chain ID | Description |
|---|---|---|---|
polygon-amoy | eip155:80002 | 80002 | Polygon Amoy testnet |
polygon | eip155:137 | 137 | Polygon PoS mainnet |
base-sepolia | eip155:84532 | 84532 | Base Sepolia testnet |
base | eip155:8453 | 8453 | Base mainnet |
ethereum | eip155:1 | 1 | Ethereum mainnet |
sepolia | eip155:11155111 | 11155111 | Ethereum Sepolia testnet |
Package migration reference
| V1 package | V2 package(s) |
|---|---|
x402 | @x402/core |
x402-express | @x402/express |
x402-axios | @x402/axios |
x402-fetch | @x402/fetch |
x402-hono | @x402/hono |
x402-next | @x402/next |
| (built-in) | @x402/evm (EVM support) |
Header changes
If you implement custom HTTP handling, update header names:Troubleshooting
Payment verification failures
- Use CAIP-2 network identifiers (
eip155:80002oreip155:137), notpolygon-amoyorpolygon - Verify your
payToaddress is correct - Confirm the facilitator URL matches the network:
- Amoy:
https://x402-amoy.polygon.technology - Mainnet:
https://x402.polygon.technology
- Amoy: