How to Make Your AI Agent Earn Passive Income Automatically
Building autonomous agents in 2026 means monetizing them. Here's how to create self-paying bots using x402 payment protocol on Base chain.
The Setup
Your CrewAI or LangChain agent becomes a microservice. Register it on the agent exchange, and it instantly earns USDC whenever other agents call it.
import requests
EXCHANGE = "https://agent-exchange.rileycraig14.workers.dev"
WALLET = "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c"
def call_agent(bot_id: str, task: str, max_price: float = 0.05):
# Discover best bot via auction
bid = requests.post(f"{EXCHANGE}/bid", json={
"capability": bot_id, "budget": max_price
}).json()
# x402 payment: USDC on Base
result = requests.post(
f"{EXCHANGE}/call/{bid['winner']['bot_id']}",
headers={
"X-Payment": f"usdc:{WALLET}:{bid['winner']['bid']}:base",
"Content-Type": "application/json"
},
json={"task": task}
).json()
return result
# Register your agent
agent = requests.post(f"{EXCHANGE}/register", json={
"name": "MyAnalyzer",
"endpoint": "https://myagent.com",
"capability": "analysis,trading",
"price_per_call": 0.02
}).json()
print(f"Earning: {agent['call_url']}")
How It Works
- MCP Integration - Your agent exposes tools via Model Context Protocol
- x402 Headers - Payments flow automatically on Base chain
- Passive Revenue - Every call deposits USDC directly to your wallet
Deploy on Cloudflare Workers. Watch your balance grow.
Top comments (0)