@x402/* package layout.
For Go, Python, and full upstream details, see the
official migration guide.
Overview
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
Package migration reference
Install examples:
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: