How I Built an Autonomous AI Agent That Earns USDC While I Sleep
Description and use
An autonomous agent on a VPS uses an LLM to perform tasks, pays for them via x402, receives USDC, and automatically reinvests profits.
Problem
Developers want a repeatable, low‑cost system that autonomously performs a billable task, receives stablecoin payment, and reinvests profits without relying on proprietary SaaS.
Outcome
The agent processed jobs continuously for three weeks on a single‑GPU VPS, earning USDC with minimal overhead and automatically reinvesting surplus.
Workflow
- 1. Pull job from Redis/SQLite queue
- 2. Execute job via LM adapter (OpenAI or local Llama‑2‑7B via TGI)
- 3. Build x402 payment payload and send request to protected endpoint
- 4. Receive 402 response, sign USDC transfer with wallet, retry request
- 5. Verify USDC receipt on Base, log profit, sweep excess to profit address
- 6. Sleep 5 s and repeat
Evidence
The agent never holds more than the USDC needed to pay for the next call; any excess is swept to a separate “profit” address hourly.
I selected Llama‑2‑7B served via text‑generation‑inference (TGI) on a single‑GPU VPS.
- Record date: 2026-09-16T21:30:35.511Z