Available Examples
A2A Protocol
Agent-to-Agent protocol implementation with X402 extension.- Best for: AI agents and autonomous systems
- Networks: Base (EVM), Solana (SVM)
- Complexity: Simple
- Features: Agent discovery, JSON-RPC 2.0, async payments
x402-axios (v2)
The simplest integration using axios with x402 v2 payment client.- Best for: Most web applications
- Networks: Base (EVM), Solana (SVM)
- Complexity: Simple
- Dependencies: Minimal
Coinbase CDP SDK
Server-side wallet management with MPC security.- Best for: Backend applications, enterprises
- Networks: Base (EVM), Solana (SVM)
- Complexity: Moderate
- Key management: MPC-based, no private keys needed
x402-fetch (v2)
Minimal integration using x402 v2 with axios under the hood.- Best for: Node.js apps, minimal footprint
- Networks: Base (EVM), Solana (SVM)
- Complexity: Simple
- Dependencies: Minimal
thirdweb
Managed infrastructure with thirdweb’s payment API.- Best for: Apps using thirdweb ecosystem
- Network: Base (EVM)
- Complexity: Moderate
- Key management: Managed by thirdweb
Crossmint Smart Wallets
Smart contract wallets with account abstraction.- Best for: Apps needing smart wallet features
- Network: Base (EVM)
- Complexity: Moderate
- Features: Account abstraction, smart wallets
Comparison Matrix
| Example | Network(s) | Private Keys | Complexity | Best For |
|---|---|---|---|---|
| A2A | Base, Solana | Direct | ⭐ Simple | AI agents |
| axios | Base, Solana | Direct | ⭐ Simple | Most apps |
| CDP SDK | Base, Solana | MPC managed | ⭐⭐ Moderate | Enterprises |
| fetch | Base, Solana | Direct | ⭐ Simple | Node.js apps |
| thirdweb | Base | Managed | ⭐⭐ Moderate | thirdweb users |
| Crossmint | Base | Smart wallet | ⭐⭐ Moderate | Smart wallets |
Quick Start
Each example follows the same structure:- Clone or copy the example code
- Install dependencies:
npm install - Configure environment: Copy
.env.exampleto.env - Add credentials: Private key and receiver username
- Run:
npm run dev
Common Prerequisites
All examples require:- Node.js 18+
- USDC balance on the target network
- Receiver username: Use your own X account for testing
Supported Platforms
All examples support sending payments to:- X (Twitter) -
/payments/x/pay - Farcaster -
/payments/farcaster/pay - GitHub -
/payments/github/pay
Network Support
| Network | axios | CDP SDK | fetch | thirdweb | Crossmint |
|---|---|---|---|---|---|
| Base | ✅ | ✅ | ✅ | ✅ | ✅ |
| Solana | ✅ | ✅ | ✅ | ❌ | ❌ |
Choosing the Right Example
Use A2A if you’re:
- Building AI agents or autonomous systems
- Need agent discovery capabilities
- Want JSON-RPC based communication
- Implementing agent-to-agent payments
Use axios if you want:
- Simplest integration
- Familiar HTTP client
- Minimal setup
- Both Base and Solana support
Use CDP SDK if you want:
- Enterprise-grade security
- No direct private key management
- Server-side wallets
- Both Base and Solana support
Use fetch if you want:
- Minimal dependencies
- Simple integration
- Both Base and Solana support
Use thirdweb if you’re:
- Already using thirdweb
- Building on their infrastructure
- Need their ecosystem tools
Use Crossmint if you need:
- Smart contract wallets
- Account abstraction
- Advanced wallet features
Integration Steps
1. Choose Your Example
Pick the example that matches your stack and requirements.2. Set Up Environment
All examples use environment variables for configuration:3. Install Dependencies
4. Run the Example
Testing Tips
- Start small: Use 0.01 USDC (1 cent) for initial tests
- Test on yourself: Send to your own X account
- Check balance: Ensure sufficient USDC + gas fees
- Verify receipt: Click the receipt URL to confirm payment
Example Output
All examples produce similar output:Source Code
All example source code is available on GitHub: View examples repository → Each example includes:- Complete TypeScript implementation
- Environment configuration
- README with setup instructions
- package.json with dependencies
Next Steps
- Choose an example that fits your needs
- Follow the guide for that specific example
- Integrate into your application
- Refer to API docs for advanced usage
Additional Resources
- Getting Started - Quick API overview
- x402 Protocol - Understanding x402
- API Reference - Complete API docs
- CLI Tool - Command-line interface
Getting Help
- GitHub Issues: Report bugs or request features
- Documentation: Comprehensive guides for each example
- API Support: Contact via snack.money