Skip to main content
Explore different ways to integrate Snack Money’s x402 v2 payment API into your application. Each example demonstrates a complete implementation with a different SDK or infrastructure provider.

Available Examples

MCP Protocol

Model Context Protocol with x402 payments for AI tool calling.
  • Best for: AI agents and LLMs with tool calling capabilities
  • Networks: Base (EVM), Solana (SVM)
  • Complexity: Simple
  • Features: JSON-RPC 2.0, tool discovery, automatic payment handling
View full example →

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
View full example →

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
View full example →

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
View full example →

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
View full example →

thirdweb

Managed infrastructure with thirdweb’s payment API.
  • Best for: Apps using thirdweb ecosystem
  • Network: Base (EVM)
  • Complexity: Moderate
  • Key management: Managed by thirdweb
View full example →

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
View full example →

Comparison Matrix

Quick Start

Each example follows the same structure:
  1. Clone or copy the example code
  2. Install dependencies: npm install
  3. Configure environment: Copy .env.example to .env
  4. Add credentials: Private key and receiver username
  5. 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

Choosing the Right Example

Use MCP if you’re:

  • Building AI agents with tool calling
  • Integrating with Claude, GPT, or other LLMs
  • Need standardized tool discovery
  • Want automatic payment handling in AI workflows

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

  1. Start small: Use 0.01 USDC (1 cent) for initial tests
  2. Test on yourself: Send to your own X account
  3. Check balance: Ensure sufficient USDC + gas fees
  4. 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

  1. Choose an example that fits your needs
  2. Follow the guide for that specific example
  3. Integrate into your application
  4. Refer to API docs for advanced usage

Additional Resources

Getting Help

  • GitHub Issues: Report bugs or request features
  • Documentation: Comprehensive guides for each example
  • API Support: Contact via snack.money