Support for x402 protocol v2
Joaquim VergesThe thirdweb SDK now supports x402 protocol version 2, introducing header-based payment flows for improved efficiency and flexibility in blockchain payment integrations.
- New Payment Headers: v2 uses
PAYMENT-SIGNATUREfor requests andPAYMENT-RESPONSEfor responses, replacing the v1 headers (X-PAYMENTandX-PAYMENT-RESPONSE) - Streamlined Responses: Payment requirements are now encoded in the
PAYMENT-REQUIREDheader rather than the response body, reducing payload size - Backward Compatibility: The SDK maintains full backward compatibility with v1, automatically detecting and handling both protocol versions
Payment data retrieval now prioritizes v2 headers with fallback to v1:
This change applies to:
settlePayment()- Server-side payment settlementverifyPayment()- Payment verification- Middleware implementations
New optional x402Version parameter allows explicit version control:
No breaking changes - existing v1 integrations continue to work unchanged. To adopt v2:
- Update header reading to check both headers (as shown above)
- Optionally specify
x402Version: 2in configuration - The SDK handles version negotiation automatically
For complete implementation details and examples, see the documentation.