Client examples
- Minimal integration
- Full example (Node + viem)
- React example (wagmi + viem)
Workflow
- Call the protected resource → receive 402
- Parse
accepts→ choose one requirements - Generate payment signature (Permit/EIP-3009/Permit2)
- Set
X-Paymentand retry request → receive 200
Best practices
- Always set
maxValueto prevent overpayment - For resources with multiple options, pass a selector to prioritize a token
- Print the payload and 402 body on failures for troubleshooting
FAQs
- Insufficient balance/expired/nonce error → re-sign as instructed
- Failures after network switch → ensure
networkmatches the requirements