Skip to content

Comments

integrate v2, add EVM multi-chain support#14

Merged
Zlerp merged 12 commits intomainfrom
v2-integration
Jan 8, 2026
Merged

integrate v2, add EVM multi-chain support#14
Zlerp merged 12 commits intomainfrom
v2-integration

Conversation

@Zlerp
Copy link
Collaborator

@Zlerp Zlerp commented Jan 6, 2026

Note

Enables protocol v2 by default with CAIP-2 identifiers and updated HTTP transport, plus flexible network/token support.

  • Implement versioned strategies (versions/v1, versions/v2) with new headers (PAYMENT-SIGNATURE, PAYMENT-RESPONSE, PAYMENT-REQUIRED) and CAIP-2 network formatting
  • Update controller paywall to support per-endpoint versioning, emit v2 requirement header, match accepts, and set correct response headers; add robust 402 generation
  • Add multi-chain acceptance via config.accept and per-accept wallet addresses; refactor requirement generation to output v1/v2 formats
  • Add custom EVM chain/token registration and CAIP-2 conversion helpers; extend chains with Solana (incl. fee payer) and adjust validator to handle Solana transactions
  • Revise PaymentPayload/PaymentRequirement to v2 shapes (amount, nested accepted, top-level resource) while keeping v1 compatibility
  • Bump gem to 1.0.0; update README, CHANGELOG, initializer, and tests to cover new behaviors

Written by Cursor Bugbot for commit 0ec2b24. This will update automatically on new commits. Configure here.

Added note about token support for facilitators.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR integrates x402 protocol v2 with significant architectural changes to support multi-chain payments, CAIP-2 network identifiers, and a version strategy pattern. The default protocol version is now v2, with backward compatibility for v1 maintained through a strategy pattern.

Key changes:

  • Implements version strategy pattern (V1, V2) with protocol-specific headers, network formats, and requirement structures
  • Adds multi-chain payment support via config.accept() allowing simultaneous acceptance of payments on multiple chains
  • Introduces custom chain and token registration for EVM networks beyond built-in options
  • Updates PaymentRequirement and PaymentPayload to handle both v1 and v2 formats with CAIP-2 network normalization

Reviewed changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
spec/x402/versions/v2_spec.rb Comprehensive tests for v2 strategy: CAIP-2 formatting, PAYMENT-SIGNATURE header, amount field usage
spec/x402/versions/v1_spec.rb Tests for v1 legacy strategy: internal network format, X-PAYMENT header, maxAmountRequired field
spec/x402/requirement_generator_spec.rb Tests for multi-version requirement generation, multiple accepts, Solana support, and version overrides
spec/x402/configuration_spec.rb Tests for custom chain/token registration, multi-chain accept configuration, and effective_accepted_payments
spec/x402/chains_spec.rb Tests for CAIP-2 mapping, custom chains, token configuration, and asset address resolution
lib/x402/versions/v2.rb V2 strategy implementation with CAIP-2 formatting, new headers, and v2-specific requirement structure
lib/x402/versions/v1.rb V1 legacy strategy with internal network format and original header names
lib/x402/versions/base.rb Abstract base class defining version strategy interface
lib/x402/versions.rb Factory method for version strategy instantiation
lib/x402/requirement_generator.rb Updated to support multi-chain accepts, version-specific formatting, and Solana fee payer handling
lib/x402/rails/controller_extensions.rb Enhanced paywall logic with version-aware headers, network matching, and requirement generation
lib/x402/payment_requirement.rb Added version-aware to_h method, CAIP-2 network normalization, and max_amount_required alias
lib/x402/payment_payload.rb Extended for v2 with accepted/resource_info fields, network normalization, and version-specific serialization
lib/x402/configuration.rb Added accept(), register_chain(), register_token() methods and version/fee_payer configuration
lib/x402/chains.rb Extended with Solana chains, CAIP-2 mapping, custom chain support, and fee payer configuration
lib/x402/rails/version.rb Bumped version to 1.0.0 for v2 protocol support
lib/x402/rails/generators/templates/x402_initializer.rb Updated default facilitator URL to include www subdomain
README.md Added extensive documentation for v2 features, custom chains/tokens, multi-chain accepts, and protocol versions
CHANGELOG.md Documents v2 integration, multi-chain support, and breaking changes
Gemfile.lock Updated to reflect new gem version 1.0.0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@luccastera luccastera self-requested a review January 7, 2026 22:00
luccastera
luccastera previously approved these changes Jan 7, 2026
@Zlerp Zlerp merged commit ff0d3df into main Jan 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants