AI-Powered Autonomous Payment Agent on Stellar using x402 Protocol
StellarPayAgent is an early-stage JavaScript project in the AI payments / x402 ecosystem. It currently has 0 GitHub stars and 0 forks.
Autonomous AI Agents that Buy, Sell, and Earn on Stellar via x402
The internet runs on APIs. AI agents run on intelligence. But until now, agents couldn't pay for the resources they need. StellarPayAgent changes that.
StellarPayAgent is a complete platform where AI agents autonomously transact using the x402 payment protocol on Stellar. Agents discover services, negotiate prices, make micropayments in XLM/USDC, and receive data -- all without human intervention.
Built for Stellar Hacks: Agents
Run the full multi-agent demo to see 3 AI agents trading services on Stellar:
npm install
node src/demo.js
This creates 3 agents, registers 4 marketplace services, and executes 5 real on-chain transactions -- all verifiable on Stellar Explorer.
AI agents can reason, plan, and act -- but they hit a wall when they need to pay for an API call, unlock premium data, or purchase a service from another agent. Subscription models and API keys don't work for autonomous machines.
StellarPayAgent implements the x402 protocol on Stellar, turning any HTTP endpoint into a paid resource. When an agent encounters a paywall:
Agent requests data --> Server returns HTTP 402 + payment requirements
Agent pays on Stellar --> < 5 seconds, ~$0.00001 fee
Agent retries with TX proof --> Server verifies on-chain, delivers data
| Feature | Description |
|---|---|
| x402 Payment Protocol | HTTP 402 paywalls with on-chain Stellar verification |
| Agent Marketplace | Service registry where agents buy/sell data and compute |
| Multi-Currency | XLM + USDC stablecoin support |
| MCP Server | Model Context Protocol integration for any AI assistant |
| Claude AI Brain | Natural language agent control via Anthropic Claude |
| OpenClaw Skill | Portable AI agent skill for wallet and payment operations |
| Web Dashboard | Real-time monitoring of agents, transactions, and marketplace |
┌─────────────────────────────────────────────────────────────────┐
│ StellarPayAgent Platform │
├──────────────┬───────────────┬──────────────┬───────────────────┤
│ Claude AI │ x402 Protocol │ Marketplace │ MCP Server │
│ (Brain) │ (Payment) │ (Commerce) │ (AI Integration) │
│ │ │ │ │
│ Understands │ HTTP 402 │ Register │ Expose tools to │
│ commands & │ challenges & │ services & │ any MCP-capable │
│ decides │ on-chain │ auto-trade │ AI assistant │
│ actions │ verification │ between │ (Claude, GPT, │
│ │ │ agents │ OpenClaw, etc) │
├──────────────┴───────────────┴──────────────┴───────────────────┤
│ Stellar Blockchain (Testnet) │
│ XLM payments | USDC stablecoin | < 5s settlement │
│ Fees: ~$0.00001 | On-chain verifiable │
└─────────────────────────────────────────────────────────────────┘
The demo showcases a real economic workflow:
Data Provider ←──── sells market data (1 XLM) ────→ Researcher
Data Provider ←──── sells on-chain metrics (1.5 XLM) → Researcher
Analyst ←──── sells sentiment report (2 XLM) ──→ Researcher
Analyst ←──── sells investment report (3 XLM) ──→ Researcher
Data Provider ←──── sells market data (1 XLM) ────→ Analyst
Total: 5 transactions, 8.5 XLM volume, 3 agents, fully autonomous
git clone https://github.com/hamdyx2202/StellarPayAgent.git
cd StellarPayAgent
npm install
node src/demo.js # Run multi-agent demo (no API key needed)
node src/server.js # Start server + dashboard at http://localhost:3000
node src/mcp-server.js # Start MCP server for AI assistant integration
| Endpoint | Price | Description |
|---|---|---|
GET /api/market-data |
1 XLM | Crypto market prices and trends |
GET /api/ai-analysis |
2 XLM | AI-generated market analysis |
GET /api/weather |
0.5 XLM | Weather data for any city |
GET /api/sentiment |
1.5 XLM | Social sentiment analysis |
# 1. Request without payment -> HTTP 402 with payment requirements
curl http://localhost:3000/api/market-data
# Response: { x402Version: 1, accepts: [{ scheme: "exact", network: "stellar:testnet", price: "1", payTo: "G..." }] }
# 2. Pay on Stellar (agent does this automatically)
# 3. Retry with proof
curl -H "X-Payment-Proof: <stellar_tx_hash>" http://localhost:3000/api/market-data
The Claude-powered agent supports:
| Tool | Description | Cost |
|---|---|---|
create_wallet |
Create Stellar wallet (XLM + USDC) | Free |
check_balance |
Check any agent's balance | Free |
send_payment |
Send XLM or USDC | Free |
access_paid_api |
Auto-pay x402 endpoints | Varies |
discover_services |
Browse marketplace | Free |
purchase_service |
Buy from another agent | Varies |
marketplace_stats |
View trading statistics | Free |
The MCP server exposes these tools for any AI assistant:
create_stellar_wallet - Create and fund walletscheck_balance - Query XLM/USDC balancessend_xlm / send_usdc - Make paymentsadd_usdc_trustline - Enable USDC for a walletget_market_data [PREMIUM] - Paid market dataget_ai_analysis [PREMIUM] - Paid AI analysisAdd to your AI assistant's MCP config:
{
"mcpServers": {
"stellar-pay-agent": {
"command": "node",
"args": ["src/mcp-server.js"],
"cwd": "/path/to/StellarPayAgent"
}
}
}
StellarPayAgent ships as an OpenClaw skill for portable AI agent capabilities:
# Install the skill
cp -r openclaw-skill ~/.openclaw/skills/stellar-pay-agent
The skill teaches any OpenClaw-powered agent to create wallets, make payments, and handle x402 paywalls on Stellar.
StellarPayAgent/
├── src/
│ ├── wallet.js # Stellar wallet operations (XLM + USDC)
│ ├── x402.js # x402 payment protocol implementation
│ ├── agent.js # Claude AI agent with tool use
│ ├── marketplace.js # Agent service marketplace
│ ├── mcp-server.js # MCP server for AI integration
│ ├── server.js # Express server + x402 paid APIs
│ └── demo.js # Multi-agent demo
├── public/
│ └── index.html # Web dashboard
├── openclaw-skill/
│ └── SKILL.md # OpenClaw agent skill
├── package.json
└── README.md
| Component | Technology |
|---|---|
| AI Engine | Claude (Anthropic) |
| Blockchain | Stellar (Testnet/Mainnet) |
| Protocol | x402 (HTTP 402 Payment Required) |
| Stablecoin | USDC on Stellar |
| MCP | Model Context Protocol |
| Agent Framework | OpenClaw compatible |
| Backend | Node.js + Express |
| SDK | @stellar/stellar-sdk, @modelcontextprotocol/sdk |
Successfully executed on Stellar Testnet:
Most hackathon projects show a single agent making a single payment. StellarPayAgent demonstrates a complete economic system:
MIT
Built for Stellar Hacks: Agents -- Exploring what happens when AI agents can buy, sell, coordinate, and earn on Stellar.
The agent-native LLM router for OpenClaw. 41+ models, <1ms routing, USDC payments on Base & Solana via x402.
A payments protocol for the internet. Built on HTTP.
A local-first AI agent with persistent memory, emotional intelligence, and a peer-to-peer skills economy.
Self-healing infrastructure for AI agent payments. 90.3% auto-recovery.
The AI agent with a wallet — spends USDC autonomously to get real work done. Apache-2.0, TypeScript.
Daydreams is a set of tools for building agents for commerce