Get the FREE Ultimate OpenClaw Setup Guide →

a2a-x402

The A2A x402 Extension brings cryptocurrency payments to the Agent-to-Agent (A2A) protocol, enabling agents to monetize their services through on-chain payments. This extension revives the spirit of HTTP 402 "Payment Required" for the decentralized agent ecosystem.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio google-agentic-commerce-a2a-x402 python -m x402_a2a \
  --env A2A_X402_NETWORK="mainnet or testnet placeholder" \
  --env A2A_X402_PRIVATE_KEY="your-private-key (securely stored)" \
  --env A2A_X402_RPC_ENDPOINT="https://example-rpc-endpoint"

How to use

A2A x402 is an extension that enables agent-to-agent services to be paid on-chain using the x402 protocol. It provides a library (primarily Python in this repo) that implements core payment data structures, signing/verification utilities, and executors to automate the payment flow. To use it, integrate the x402_a2a library into your A2A agent so that when you offer a paid capability, your agent can respond with a payment-required message, accept a payment-submitted message from the client, and finalize with a payment-completed message. The repository also includes example applications demonstrating how to wire the library into real agents and how to invoke typical payment flows. In short, you can convert any A2A agent into a commercial service by wiring in the x402 core and executors to handle on-chain payments for API calls, data processing, AI inference, or other valuable services.

How to install

Prerequisites:

  • Python 3.8+ and pip
  • Git
  • Virtual environment (recommended)

Install steps:

  1. Clone the repository: git clone https://github.com/your-org/google-agentic-commerce-a2a-x402.git cd google-agentic-commerce-a2a-x402

  2. (Optional) Create and activate a virtual environment: python3 -m venv .venv source .venv/bin/activate # on Unix/macOS .venv\Scripts\activate # on Windows

  3. Install Python dependencies for the x402 a2a library (adjust path if structure differs): if a requirements file exists: python -m pip install -r python/x402_a2a/requirements.txt otherwise install the package directly from source: python -m pip install -e python/x402_a2a

  4. Run or test the library/examples: python -m x402_a2a

Notes:

  • The exact package name may vary; look for the Python implementation under python/x402_a2a in this repo for precise usage instructions.
  • Ensure your environment variables (see mcp_config) are set to point at your network, RPC endpoint, and keys in a secure manner.

Additional notes

Tips and common issues:

  • This extension is designed as a protocol library; you will typically run the Python module that provides the x402_a2a implementation and integrate it into your agent's middleware.
  • Ensure you securely manage private keys and RPC endpoints; avoid hard-coding credentials.
  • When testing, use a testnet or sandbox environment if available for on-chain payments before going live on mainnet.
  • Refer to the spec at spec/v0.1/spec.md and the Python library documentation under python/x402_a2a/README.md for deeper integration details and examples.
  • If you encounter module import errors, verify your PYTHONPATH includes the repository's python/x402_a2a directory or install the package in editable mode as shown above.

Related MCP Servers

Sponsor this space

Reach thousands of developers