> ## Documentation Index
> Fetch the complete documentation index at: https://docs.snack.money/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Production-ready integration examples with various x402 v2 clients

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

```typescript theme={null}
// Discover available tools
POST https://api.snack.money/mcp
{
  "jsonrpc": "2.0",
  "method": "tools/list",
  "id": 1
}

// Call a tool with payment
POST https://api.snack.money/mcp
{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "pay_twitter",
    "arguments": {
      "receiver": "username",
      "amount": 0.01
    }
  }
}
```

[View full example →](/examples/mcp)

### 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

```typescript theme={null}
// Discover agent capabilities
GET https://api.snack.money/a2a/.well-known/agent-card

// Send payment via JSON-RPC
POST https://api.snack.money/a2a
{
  "jsonrpc": "2.0",
  "method": "snack-money.pay.twitter",
  "params": {
    "receiver": "username",
    "amount": 0.01
  }
}
```

[View full example →](/examples/a2a)

### 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

```typescript theme={null}
import { x402Client, wrapAxiosWithPayment } from "@x402/axios";
import { registerExactEvmScheme } from "@x402/evm/exact/client";

const client = new x402Client();
registerExactEvmScheme(client, { signer: account });

const api = wrapAxiosWithPayment(
  axios.create({ baseURL: "https://api.snack.money" }),
  client
);

await api.post("/payments/x/pay", {
  amount: 0.01,
  currency: "USDC",
  receiver: "username"
});
```

[View full example →](/examples/axios)

### 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

```typescript theme={null}
const privateKey = await cdpClient.evm.exportAccount({ address: walletAddress });
const account = privateKeyToAccount(`0x${privateKey}`);

const client = new x402Client();
registerExactEvmScheme(client, { signer: account });

const api = wrapAxiosWithPayment(
  axios.create({ baseURL: "https://api.snack.money" }),
  client
);
```

[View full example →](/examples/cdp-sdk)

### 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

```typescript theme={null}
import { x402Client, wrapAxiosWithPayment } from "@x402/axios";
import { registerExactEvmScheme } from "@x402/evm/exact/client";

const client = new x402Client();
registerExactEvmScheme(client, { signer: account });

const api = wrapAxiosWithPayment(
  axios.create({ baseURL: "https://api.snack.money" }),
  client
);
```

[View full example →](/examples/fetch)

### thirdweb

Managed infrastructure with thirdweb's payment API.

* **Best for**: Apps using thirdweb ecosystem
* **Network**: Base (EVM)
* **Complexity**: Moderate
* **Key management**: Managed by thirdweb

```typescript theme={null}
const wallet = new PrivateKeyWallet({
  client,
  privateKey: process.env.THIRDWEB_PRIVATE_KEY
});

// Use with x402 wrapper
```

[View full example →](/examples/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

```typescript theme={null}
const wallet = CrossmintSmartWallet.build({
  config: { chain: "base" },
  signer: { type: "DEVELOPER_CONTROLLED" }
});

// Use with viem-compatible interface
```

[View full example →](/examples/crossmint)

## Comparison Matrix

| Example       | Network(s)   | Private Keys | Complexity  | Best For        |
| ------------- | ------------ | ------------ | ----------- | --------------- |
| **MCP**       | Base, Solana | Direct       | ⭐ Simple    | AI tool calling |
| **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:

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

| Network    | MCP | A2A | axios | CDP SDK | fetch | thirdweb | Crossmint |
| ---------- | --- | --- | ----- | ------- | ----- | -------- | --------- |
| **Base**   | ✅   | ✅   | ✅     | ✅       | ✅     | ✅        | ✅         |
| **Solana** | ✅   | ✅   | ✅     | ✅       | ✅     | ❌        | ❌         |

## 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:

```bash theme={null}
# For EVM networks (Base)
EVM_PRIVATE_KEY=0x...
RECEIVER=your_x_username
AMOUNT=0.01

# For Solana network (SVM)
SVM_PRIVATE_KEY=base58_key...

# Additional keys for specific examples
ANTHROPIC_API_KEY=sk-ant-...  # For AI features
CDP_API_KEY_ID=...            # For CDP SDK
THIRDWEB_SECRET_KEY=...       # For thirdweb
CROSSMINT_API_KEY=...         # For Crossmint
```

### 3. Install Dependencies

```bash theme={null}
cd examples/<example-name>
npm install
```

### 4. Run the Example

```bash theme={null}
npm run dev
```

## 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:

```
🚀 Starting Snack Money payment example

✅ Signer/wallet created
💸 Sending 0.01 USDC to @username on X...

✅ Payment successful!

📊 Response: {
  "code": 200,
  "msg": "0.01 USDC sent successfully",
  "data": {
    "txn_id": "...",
    "amount": 0.01,
    "receipt": "https://snack.money/x/username?txn=..."
  }
}
```

## Source Code

All example source code is available on GitHub:

[View examples repository →](https://github.com/snack-money/snack-money-examples)

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 Started**](/introduction/getting-started) - Quick API overview
* [**x402 Protocol**](/introduction/x402) - Understanding x402
* [**API Reference**](/api-reference/introduction) - Complete API docs
* [**CLI Tool**](/cli/overview) - Command-line interface

## Getting Help

* **GitHub Issues**: Report bugs or request features
* **Documentation**: Comprehensive guides for each example
* **API Support**: Contact via [snack.money](https://snack.money)
