Skip to main content

What is A2A?

A2A (Agent-to-Agent) is a JSON-RPC 2.0 based protocol that enables AI agents to discover and communicate with each other. Snack Money implements A2A with the X402 extension, combining agent discovery with cryptocurrency payments.

Key Features

  • Agent Discovery - Automatic service discovery via agent cards
  • JSON-RPC 2.0 - Standard protocol for agent communication
  • X402 Extension - Integrated crypto payment capabilities
  • Multi-Network - Support for both Base and Solana networks
  • Task-Based Flow - Asynchronous payment processing
  • 6 Payment Platforms - Twitter, Farcaster, GitHub, Email, Web, Instagram

How A2A Works with Snack Money

1. Discovery Phase

Agents discover Snack Money’s capabilities through the agent card:
GET https://api.snack.money/a2a/.well-known/agent-card
The agent card describes:
  • Available payment skills (e.g., snack-money.pay.twitter)
  • Required parameters and schemas
  • Supported X402 extension

2. Payment Request

Agents send JSON-RPC requests to initiate payments:
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "snack-money.pay.twitter",
  "params": {
    "receiver": "username",
    "amount": 0.01,
    "description": "Payment via A2A",
    "meta": {
      "agent_name": "my-agent"
    }
  }
}

3. Payment Requirements

Snack Money responds with payment requirements:
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "taskId": "task_abc123",
    "status": "PAYMENT_REQUIRED",
    "payment": {
      "network": "eip155:8453",
      "amount": "10000",
      "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "recipient": "0x..."
    }
  }
}

4. On-Chain Payment

The agent executes the USDC transfer on the specified network (Base or Solana).

5. Payment Proof Submission

After blockchain confirmation, the agent resubmits with proof:
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "snack-money.pay.twitter",
  "params": {
    "receiver": "username",
    "amount": 0.01,
    "taskId": "task_abc123",
    "payment": {
      "network": "eip155:8453",
      "transactionHash": "0x..."
    }
  }
}

6. Completion

Snack Money verifies the payment and returns success:
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "taskId": "task_abc123",
    "status": "PAYMENT_CONFIRMED",
    "metadata": {
      "x402:transactionId": "1234567890",
      "x402:receipt": "https://snack.money/x/username?txn=1234567890"
    }
  }
}

Available Skills

Snack Money exposes the following A2A skills:

Single Payments

  • snack-money.pay.twitter - Send to Twitter/X users
  • snack-money.pay.farcaster - Send to Farcaster users
  • snack-money.pay.github - Send to GitHub users
  • snack-money.pay.email - Send to email addresses
  • snack-money.pay.web - Send to web domains
  • snack-money.pay.instagram - Send to Instagram users

Batch Payments

  • snack-money.batch-pay.twitter - Batch payments to Twitter users
  • snack-money.batch-pay.farcaster - Batch payments to Farcaster users
  • snack-money.batch-pay.github - Batch payments to GitHub users
  • snack-money.batch-pay.email - Batch payments to email addresses
  • snack-money.batch-pay.web - Batch payments to web domains
  • snack-money.batch-pay.instagram - Batch payments to Instagram users

Required Headers

When making A2A requests, include:
Content-Type: application/json
X-A2A-Extensions: https://a2a.dev/spec/extensions/x402/v0

Network Support

Base (EVM)

  • Network ID: eip155:8453
  • Token: USDC (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913)
  • Use EVM private key for signing

Solana (SVM)

  • Network ID: solana:mainnet
  • Token: USDC SPL token
  • Use Solana private key for signing

Integration Example

For complete working examples, see the A2A Examples page or check out the snack-money-examples/a2a repository.

Why A2A + X402?

The combination of A2A and X402 protocols provides:
  1. Agent Interoperability - Agents can discover and use services automatically
  2. Payment Integration - Native crypto payments without manual setup
  3. Standardized Communication - JSON-RPC 2.0 ensures compatibility
  4. Decentralized - No central authority or intermediary required
  5. Multi-Chain - Support for different blockchain networks

Learn More