Skip to content

Comments

feat(ruby): Add complete Ruby SDK implementation for x402 protocol#1240

Open
mfix-stripe wants to merge 1 commit intocoinbase:mainfrom
mfix-stripe:feat/ruby-sdk-implementation
Open

feat(ruby): Add complete Ruby SDK implementation for x402 protocol#1240
mfix-stripe wants to merge 1 commit intocoinbase:mainfrom
mfix-stripe:feat/ruby-sdk-implementation

Conversation

@mfix-stripe
Copy link

Implements a full-featured Ruby SDK with feature parity to the Python SDK, following repository conventions and Ruby idioms.

Core Components:

  • X402::Client - Payment creation with policy system and lifecycle hooks
  • X402::ResourceServer - Resource protection with verification/settlement
  • X402::Facilitator - Payment verification and on-chain settlement

Blockchain Support:

  • EVM mechanism (production-ready):
    • EIP-3009 TransferWithAuthorization for USDC
    • EIP-712 typed data signing
    • Networks: Ethereum, Base, Polygon, Avalanche, MegaETH
    • Private key signer with eth gem
  • SVM mechanism (simplified):
    • Solana transaction support
    • Networks: mainnet, devnet, testnet
    • Ed25519 signing

HTTP Integration:

  • Faraday-based facilitator client
  • Rack middleware for universal web framework support
  • Base64 encoding/decoding utilities
  • Rails integration ready

Type System:

  • dry-struct + dry-types for runtime validation
  • Automatic camelCase JSON serialization
  • Immutable data structures
  • Protocol-based interfaces using Ruby modules

Features:

  • Policy system (prefer_network, prefer_scheme, max_amount)
  • Lifecycle hooks (before/after/on_failure) for all operations
  • Network pattern matching with wildcards (eip155:*)
  • CAIP-2 network identifier support (V2 protocol)
  • Graceful degradation for optional dependencies

Testing:

  • Comprehensive unit tests (Client, Server, Facilitator, Schemas)
  • Integration tests for full payment flow
  • Mock payment scheme for testing
  • SimpleCov coverage reporting (80% target)
  • RSpec configuration with VCR for HTTP fixtures

Documentation:

  • README.md with installation and quick start
  • CLIENT.md - Complete client implementation guide
  • SERVER.md - Server setup and middleware integration
  • FACILITATOR.md - Deployment and operations guide
  • CONTRIBUTING.md - Development workflow and guidelines
  • CHANGELOG.md - Version history

Examples:

  • client_basic/ - Basic client with payment creation
  • server_rack/ - Rack server with payment-protected routes
  • facilitator/ - Simple facilitator service with Sinatra

Build Configuration:

  • gemspec with core and optional dependencies
  • Rakefile with test, lint, and doc tasks
  • Bundler groups for optional features (evm, svm, dev)

Dependencies:

  • Core: dry-struct, dry-types, faraday
  • Optional EVM: eth (~> 0.5)
  • Optional SVM: base58, ed25519
  • Optional Web: rack, sinatra, rails
  • Dev: rspec, rubocop, yard, webmock, vcr, simplecov

Note: ETH addresses are public USDC contract addresses. Email addresses are public project contact information.

GIT_VALID_PII_OVERRIDE

Committed-By-Agent: claude

Description

Tests

Checklist

  • I have formatted and linted my code
  • All new and existing tests pass
  • My commits are signed (required for merge) -- you may need to rebase if you initially pushed unsigned commits
  • I added a changelog fragment for user-facing changes (docs-only changes can skip)

Implements a full-featured Ruby SDK with feature parity to the Python SDK,
following repository conventions and Ruby idioms.

Core Components:
- X402::Client - Payment creation with policy system and lifecycle hooks
- X402::ResourceServer - Resource protection with verification/settlement
- X402::Facilitator - Payment verification and on-chain settlement

Blockchain Support:
- EVM mechanism (production-ready):
  - EIP-3009 TransferWithAuthorization for USDC
  - EIP-712 typed data signing
  - Networks: Ethereum, Base, Polygon, Avalanche, MegaETH
  - Private key signer with eth gem
- SVM mechanism (simplified):
  - Solana transaction support
  - Networks: mainnet, devnet, testnet
  - Ed25519 signing

HTTP Integration:
- Faraday-based facilitator client
- Rack middleware for universal web framework support
- Base64 encoding/decoding utilities
- Rails integration ready

Type System:
- dry-struct + dry-types for runtime validation
- Automatic camelCase JSON serialization
- Immutable data structures
- Protocol-based interfaces using Ruby modules

Features:
- Policy system (prefer_network, prefer_scheme, max_amount)
- Lifecycle hooks (before/after/on_failure) for all operations
- Network pattern matching with wildcards (eip155:*)
- CAIP-2 network identifier support (V2 protocol)
- Graceful degradation for optional dependencies

Testing:
- Comprehensive unit tests (Client, Server, Facilitator, Schemas)
- Integration tests for full payment flow
- Mock payment scheme for testing
- SimpleCov coverage reporting (80% target)
- RSpec configuration with VCR for HTTP fixtures

Documentation:
- README.md with installation and quick start
- CLIENT.md - Complete client implementation guide
- SERVER.md - Server setup and middleware integration
- FACILITATOR.md - Deployment and operations guide
- CONTRIBUTING.md - Development workflow and guidelines
- CHANGELOG.md - Version history

Examples:
- client_basic/ - Basic client with payment creation
- server_rack/ - Rack server with payment-protected routes
- facilitator/ - Simple facilitator service with Sinatra

Build Configuration:
- gemspec with core and optional dependencies
- Rakefile with test, lint, and doc tasks
- Bundler groups for optional features (evm, svm, dev)

Dependencies:
- Core: dry-struct, dry-types, faraday
- Optional EVM: eth (~> 0.5)
- Optional SVM: base58, ed25519
- Optional Web: rack, sinatra, rails
- Dev: rspec, rubocop, yard, webmock, vcr, simplecov

Note: ETH addresses are public USDC contract addresses. Email addresses
are public project contact information.

GIT_VALID_PII_OVERRIDE

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Committed-By-Agent: claude
@cb-heimdall
Copy link

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

@vercel
Copy link

vercel bot commented Feb 18, 2026

@mfix-stripe is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants