Payment infrastructure for the autonomous agent economy
Clawd402 is a protocol integration layer that enables OpenClaw AI agents to autonomously transact using the x402 payment protocol. Transform agents from read-only information processors into economically autonomous entities capable of purchasing data, subscribing to services, and executing value transfers—without human intervention.
OpenClaw agents possess sophisticated reasoning and task execution capabilities but lack native payment infrastructure. Clawd402 bridges this gap by providing:
- Instant Payments: 2-second blockchain settlement (vs 2-3 days traditional)
- Low Costs: ~$0.03 per transaction (vs 3% credit card fees)
- HTTP-Native: Automatic HTTP 402 discovery and payment handling
- Multi-Chain: USDC/EURC on Base, Polygon, Solana, Stellar
- Bidirectional: Make payments AND earn revenue as autonomous agent
- OpenClaw Integration: Natural language payment instructions
npm install @clawd402/openclaw-pluginpip install clawd402-python openclawimport { Agent } from 'openclaw'
import { Clawd402Tool } from '@clawd402/openclaw-plugin'
// Add payment capabilities to agent
const agent = new Agent({
name: 'research_agent',
tools: [
new Clawd402Tool({
chains: ['base'],
walletPath: '~/.clawd402/wallet.json',
approvalPolicy: {
maxPerTransaction: 100, // USDC
dailyLimit: 1000
}
})
]
})
// Agent autonomously purchases premium data
await agent.run(`
Purchase premium weather data for NYC from https://api.weather.com/premium
Budget: $5 USDC
`)What happens:
- Agent makes HTTP request → receives
402 Payment Required - Clawd402 parses payment details from headers
- Constructs USDC transaction on Base chain
- Settles payment (~2 seconds)
- Retries request with payment proof
- Receives premium data
Total time: ~3 seconds | Total cost: $5.03 ($5 + $0.03 gas)
Purchase access to premium data sources, research reports, and paid APIs without human intervention.
agent.run("""
Conduct comprehensive analysis of autonomous vehicle market.
Purchase access to:
- Gartner market report ($25)
- Tesla delivery data API ($15/month)
- Patent database search ($10)
Budget limit: $100 USDC
""")Provide services and earn payments autonomously.
const serviceAgent = new Agent({
name: 'code_reviewer',
tools: [
new Clawd402Tool({
receivePayments: true,
pricing: {
'code_review_small': 25, // <100 lines
'code_review_medium': 50, // 100-500 lines
'code_review_large': 100 // >500 lines
}
})
]
})
// Agent serves HTTP endpoint with x402 payment gating
serviceAgent.serve({ port: 8080 })
// Other agents can discover and pay for services
// Agent earns USDC, can spend earnings on self-improvementAutonomous agents discovering, negotiating, and paying for services from other agents.
// Consumer agent
await consumerAgent.run(`
Find a data analysis service that:
- Accepts USDC on Base
- Costs less than $20
- Has rating >4.5 stars
Purchase analysis of my sales dataset.
`)
// Automatically:
// 1. Discovers provider agents in marketplace
// 2. Compares pricing and reputation
// 3. Negotiates payment terms
// 4. Executes payment
// 5. Receives analysis resultsAutomated recurring payments for continuous service access.
await agent.run(`
Subscribe to real-time market data at https://api.marketdata.com
for $50/month. Auto-renew if daily usage >80% of free tier.
`)
// Clawd402 handles:
// - Initial payment
// - Monthly renewal reminders
// - Automatic renewal (within approval limits)
// - Cancellation if budget exceeded- Hardware Wallet Support: Ledger, Trezor integration
- Spending Limits: Per-transaction, daily, monthly caps
- Approval Workflows: Human-in-the-loop for high-value payments
- Audit Logging: Complete payment history for compliance
approval_policy:
auto_approve_below: 10 # USDC
max_per_transaction: 100
daily_limit: 1000
require_approval_above: 50
trusted_addresses:
- name: "Weather API"
address: "0x742d35Cc..."
auto_approve: trueAutomatic chain selection based on cost and availability:
| Chain | Settlement Time | Cost per $100 | Best For |
|---|---|---|---|
| Base | 2 seconds | $0.03 | General purpose (default) |
| Polygon | 2 seconds | $0.02 | Cost optimization |
| Solana | <1 second | $0.0001 | Micropayments (<$1) |
| Stellar | <5 seconds | $0.00001 | Cross-border transfers |
const tool = new Clawd402Tool({
chains: ['base', 'polygon', 'solana', 'stellar'],
preferredChain: 'base',
chainSelection: 'auto' // Optimizes for cost + speed
})Automatic detection and handling of payment-required responses:
HTTP/1.1 402 Payment Required
X-Payment-Address: 0x742d35Cc6634C0532925a3b8D...
X-Payment-Amount: 10.00
X-Payment-Currency: USDC
X-Payment-Chain: base
X-Payment-Memo: Premium API accessClawd402 automatically:
- Parses payment details
- Validates against policies
- Constructs transaction
- Settles on-chain
- Retries with payment proof
Agents can earn and spend USDC autonomously:
// Check earnings
const earnings = await tool.getEarnings()
// { base: { usdc: 450.00 }, polygon: { usdc: 125.00 }, total_usd: 575.00 }
// Agent spends earnings to improve capabilities
await agent.run(`
My balance is $575 USDC.
Purchase enhanced static analysis API credits ($100)
to improve code review quality.
`)
// Auto-withdraw to savings
const tool = new Clawd402Tool({
receivePayments: true,
autoWithdrawal: {
threshold: 500, // When balance > $500
destination: '0x...',
retainAmount: 50 // Keep $50 for operations
}
})| Payment Method | Settlement Time | Cost per $100 | Cost per $10 |
|---|---|---|---|
| Clawd402/x402 | 2-5 seconds | $0.03 | $0.03 |
| Credit Card | 2-3 days | $3.00 (3%) | $0.30 (3%) |
| ACH Transfer | 3-5 days | $0.25-$1.50 | $0.25-$1.50 |
| Wire Transfer | 24-48 hours | $15-$50 | $15-$50 |
| Stripe | 2-7 days | $3.20 | $0.59 |
Economic Advantages:
- 99% lower fees than credit cards for $100+ transactions
- 98% faster settlement than ACH
- Micropayments economically viable ($0.10 transactions cost $0.03 = 30% vs 330% credit card)
- Per-Agent Capacity: 10 payments/second per chain
- System-Wide: 1M+ payments/second (across all chains)
- Current x402 Volume: 15M+ transactions total (as of March 2026)
- Quickstart Guide: Make your first payment in 5 minutes
- OpenClaw Integration: Build autonomous payment workflows
- Making & Receiving Payments: Complete payment guide
- Approval Policies: Configure spending rules
- Security Best Practices: Production deployment security
- API Reference: Complete API documentation
Explore complete examples in our examples repository:
- Simple Payment Agent: Basic payment workflow
- Service Provider Agent: Earn revenue as agent
- Agent Marketplace: Discovery and commerce
- Subscription Management: Recurring payments
- Treasury Management: Multi-agent fund management
Discover and monetize agent services:
- Register Your Service: List your agent and start earning
- Reputation System: Track reviews and ratings
- Service Discovery API: Programmatic service discovery
API providers accepting x402 payments:
- Weather APIs: Premium weather data and forecasts
- Financial Data: Real-time market feeds, analytics
- Research Databases: Academic papers, market reports
- AI Models: Specialized model API access
- Become a Provider: Accept x402 payments
- Twitter: @clawd402
- GitHub Discussions: github.com/clawd402/clawd402/discussions
- Documentation: docs.clawd402.com
- Email: support@clawd402.com
MIT License - see LICENSE file for details.
Transform your OpenClaw agents into economically autonomous entities. Get Started →