GitHub Repository
View source code, examples, and contribute
npm Package
Install @b3dotfun/anyspend-x402 package
Overview
The AnySpend x402 Facilitator is a production-grade payment infrastructure that powers multi-token, cross-chain payments for the x402 protocol. It handles all the complexity of token swaps, cross-chain bridging, and settlement, allowing developers to accept payments in any token while receiving their preferred currency. Production Endpoint:https://mainnet.anyspend.com/x402
Key Capabilities
Multi-Token Payment Processing
Accept payments in any ERC-20 token that supports EIP-2612 (permit) or EIP-3009 (transferWithAuthorization):- Stablecoins: USDC, DAI, USDT (on supported chains)
- Native tokens: ETH, SOL, BNB, MATIC
- Custom tokens: Any token with permit support, including project tokens like B3
- 19+ Networks: Support across EVM chains (Base, Ethereum, Arbitrum, etc.) and SVM (Solana)
Cross-Chain Routing
Automatically handles payments across different blockchain networks:- Same-chain payments: Direct token transfers with minimal overhead
- Cross-chain payments: Automatic bridging between networks (e.g., ETH → Base)
- Cross-VM payments: Experimental support for Solana ↔ EVM transfers
- Optimal routing: Smart route selection for best execution
Automatic Token Conversion
Seamlessly converts between any supported tokens:- Buyer flexibility: Users pay with whatever token they hold
- Seller preference: Merchants receive their chosen settlement currency
- Best pricing: Routes through optimal DEX liquidity sources
- Slippage protection: Automatic safeguards against price impact
Gasless Payments
Users never pay gas fees:- Facilitator covers all on-chain gas costs
- Users only sign EIP-712 messages
- No need to hold native tokens for gas
- Smooth user experience across all chains
Standards Compliance
x402 Protocol Compliant
The AnySpend Facilitator implements the complete x402 specification:- ✅ HTTP-native payments via 402 Payment Requiredstatus
- ✅ Standard headers (X-PAYMENT,X-PAYMENT-RESPONSE,X-PREFERRED-TOKEN)
- ✅ Exact payment scheme with recipient and amount verification
- ✅ Signature-based authorization (EIP-712, EIP-2612, EIP-3009)
- ✅ Cryptographic verification without trusted third parties
Drop-in Replacement
Fully compatible with any x402 implementation:- Client compatibility: Works with any x402-compliant client
- Server compatibility: Can be used with any x402 middleware
- No vendor lock-in: Standard HTTP APIs, switch facilitators anytime
- Interoperability: Integrates with Coinbase CDP x402, PayAI, and others
Architecture
Payment Flow
Infrastructure Components
API Layer- RESTful HTTP API for payment verification and settlement
- WebSocket support for real-time payment status updates
- Rate limiting and DDoS protection
- 99.9% uptime SLA
- Aggregates liquidity from multiple DEXs
- Optimal routing for best execution prices
- Slippage protection and MEV resistance
- Cross-chain bridging integration
- Parallel transaction processing
- Automatic nonce management
- Failed transaction recovery
- Real-time settlement confirmation
- EIP-712 signature verification
- Replay attack prevention (nonce tracking)
- Deadline enforcement
- Smart contract audits
API Endpoints
POST /verify
Validates payment signature without executing on-chain. Purpose:- Fast validation (under 100ms)
- Check signature authenticity
- Verify deadline hasn’t expired
- No gas costs
POST /settle
Executes on-chain settlement and returns transaction proof. Purpose:- Execute payment authorization
- Swap tokens if needed (buyer token → seller token)
- Settle to resource server
- Return transaction hash for verification
POST /quote
Get token conversion rate for multi-token payments. Purpose:- Calculate exact token amount for payment
- Get current exchange rate
- Estimate swap execution time
GET /supported
Lists supported payment schemes and networks. Response:Integration
Server-Side (Express)
Server-Side (Custom)
Client-Side
Security
Signature Verification
All payments are verified using EIP-712 typed data signatures:- USDC: EIP-3009 transferWithAuthorization
- Other tokens: EIP-2612 permit
Replay Protection
Random Nonce (USDC):- Each signature includes unique bytes32 nonce
- Nonce can only be used once per address
- No ordering dependencies
- Token contract maintains nonce counter
- Auto-increments on each permit execution
- Prevents out-of-order execution
Deadline Enforcement
All signatures include expiration timestamps:- Default: 5 minutes from signature time
- Prevents stale payment authorizations
- Automatic rejection of expired signatures
No Private Key Access
The facilitator never has access to user private keys:- Users sign messages client-side
- Only signatures are transmitted
- Non-custodial architecture
Performance
Speed
- Verification: Under 100ms for signature validation
- Same-chain settlement: 2-10 seconds average
- Cross-chain settlement: 2-5 minutes (depends on bridging)
- Quote generation: Under 200ms
Scalability
- Handles 1000+ concurrent payments
- Horizontal scaling for high throughput
- Parallel transaction processing
- Load balancing across multiple nodes
Reliability
- 99.9% uptime guarantee
- Automatic failover and redundancy
- Failed transaction retry logic
- 24/7 monitoring and alerts
Network Support
EVM Mainnet Networks (12)
Abstract, Arbitrum, Avalanche, B3, Base, BNB Chain, Ethereum, IoTeX, Optimism, Peaq, Polygon, SeiEVM Testnets (5)
Abstract Testnet, Avalanche Fuji, Base Sepolia, Polygon Amoy, Sei TestnetSVM Networks (2)
Solana Mainnet, Solana Devnet See Network Support for complete details.Why Choose AnySpend Facilitator?
Standards Compliant
Full x402 protocol compliance - works with any compatible client or server
Production Ready
Battle-tested infrastructure with enterprise-grade reliability and performance
Multi-Chain
Support for 19+ blockchain networks with automatic cross-chain routing
Developer Friendly
Simple APIs and SDKs for Express, Next.js, Hono, and client-side TypeScript
Getting Started
Quickstart for Sellers
Start accepting multi-token payments in your API
Quickstart for Buyers
Pay with any token using the AnySpend client
Network Support
See all supported networks and tokens
Overview
Learn how AnySpend x402 works
Support
Need help with the facilitator?- Discord: discord.gg/b3dotfun
- GitHub: github.com/b3-fun/anyspend-x402
- Email: support@b3.fun
- Docs: docs.b3.fun
 HypeDuel
HypeDuel