Getting Started

This guide demonstrates how to enable AI agents to execute autonomous x402 transactions using Claw402's MCP-native architecture.

Prerequisites

Before integrating Claw402, ensure you have:

  • AI Agent Framework - OpenClaw, LangChain, AutoGPT, or custom MCP-compatible agent runtime

  • Solana Wallet - Agent wallet keypair for transaction signing (generated during setup)

  • Node.js 18+ or Python 3.9+ - Required for MCP server runtime

  • Basic MCP Knowledge - Familiarity with Model Context Protocol (optional but recommended)

What We're Building

This guide covers three integration approaches:

  1. OpenClaw Native Integration - Drop-in Python provider for OpenClaw agents (recommended)

  2. Standalone MCP Server - Framework-agnostic server for any MCP-compatible agent

  3. REST API Proxy - HTTP wrapper for non-MCP environments

Installation

Install the Claw402 provider for OpenClaw agents:

Option 2: Standalone MCP Server

Install the global MCP server:

Option 3: Docker Deployment

Run Claw402 as a containerized service:

Setup: Generate Agent Wallet

Create a dedicated wallet for your agent's transaction signing:

Security Note: Store agent wallet keypairs securely. For production deployments, use hardware security modules (HSM) or key management services.

Quick Start: OpenClaw Integration

Step 1: Configure Agent with X402Provider

Step 2: Execute Autonomous Payments

Step 3: Verify Settlement

Quick Start: Standalone MCP Server

Step 1: Launch MCP Server

approval-policy.json:

Step 2: Connect Agent to MCP Server

Configure your agent runtime to connect to the Claw402 MCP server:

Step 3: Execute Payment via MCP Tools

Agents call MCP tools using JSON schema:

Server Response:

MCP Tool Suite Reference

Claw402 exposes six core tools for agent transaction execution:

Tool
Purpose
Input Parameters
Output

x402.initialize_payment

Create payment session

amount, recipient, memo

session_id, payment_address

x402.authorize_transaction

Sign and submit transaction

session_id, approval_token

tx_signature, status

x402.verify_settlement

Confirm blockchain finality

tx_signature

confirmations, settlement_state

x402.query_balance

Retrieve wallet balances

address (optional)

balances[]

x402.estimate_fees

Calculate transaction costs

amount, priority

network_fee, total_cost

x402.cancel_payment

Abort pending transaction

session_id

cancellation_receipt

Production Example: Autonomous Invoice Settlement

This example demonstrates an accounts payable agent that processes incoming invoices autonomously:

Security Best Practices

1. Key Management

Never expose private keys in agent context windows. Use Claw402's signing service isolation:

2. Approval Policies

Implement multi-tier approval workflows for high-value transactions:

3. Transaction Limits

Configure daily/monthly spending caps:

4. Anomaly Detection

Enable circuit breakers for suspicious transaction patterns:

Monitoring and Debugging

Enable Verbose Logging

WebSocket Transaction Monitoring

Subscribe to real-time transaction events:

What's Next?

Quick Tips

  1. Start on Devnet - Test agent behavior on Solana devnet before mainnet deployment

  2. Implement Approval Policies - Never allow unrestricted autonomous spending

  3. Monitor Transaction Patterns - Set up alerting for anomalous agent behavior

  4. Use Idempotency Tokens - Prevent duplicate payments with unique session IDs

  5. Enable Circuit Breakers - Automatically suspend agents exhibiting suspicious patterns

  6. Log All Transactions - Maintain immutable audit trails for compliance

How It Works

  1. Agent receives instruction → Natural language payment intent (e.g., "Pay invoice for $250")

  2. Claw402 MCP tool invokedx402.initialize_payment called with parsed parameters

  3. Approval workflow executed → Policy engine checks thresholds and requires human confirmation if needed

  4. Transaction signed → HSM-backed signing service creates cryptographic signature (keys never enter agent context)

  5. x402 protocol execution → Transaction submitted to blockchain with settlement verification

  6. Confirmation streamed → Agent receives settlement status update via MCP response

Claw402 abstracts all blockchain complexity, enabling agents to execute payments using the same natural language interface they use for other tasks.

Last updated