How I Built an Autonomous AI Agent That Earns USDC While I Sleep
Description and use
An autonomous Python agent that uses an LLM for planning, a Redis queue for tasks, and x402 micropayments in USDC on Base, running on a cheap server.
Problem
Idle compute resources waste potential revenue; developers want a minimal example of an autonomous agent that earns micro‑payments in USDC.
Outcome
The agent processes tasks autonomously, earning $0.01‑$0.10 per task in USDC while the server remains idle, demonstrating a reusable micro‑service pattern.
Workflow
- Set up Python environment and install redis, openai, web3, eth-account, eth-utils, x402-py
- Create a Redis task queue to hold JSON‑encoded work items
- Implement a wallet module that loads or creates an Ethereum account, encrypts the private key at rest, and provides USDC contract interactions
- Write a planner that calls an OpenAI LLM to decide the next micro‑action based on current state
- Build an executor that performs HTTP requests or blockchain calls and reports success/failure
- On successful execution, trigger an x402 micropayment request to the task poster in USDC
- Run all components on a modest VM (1 vCPU, 2 GB RAM) to keep costs low
Evidence
If you have a server or a cheap VM that sits idle most of the day, you can put that compute to work performing tiny, well‑defined tasks that pay in USDC.
All components run on a single modest VM (e.g., 1 vCPU, 2 GB RAM) to keep costs low.
- Record date: 2026-09-15T06:17:25.740Z