How I Built an Autonomous AI Agent That Earns USDC While I Sleep
Description and use
Build an autonomous AI agent that earns USDC by using HTTP 402 and Base L2 to automatically accept and process paid requests.
Problem
Developers want a language‑model‑driven service that can earn micro‑payments automatically without manual top‑ups.
Outcome
The agent earns USDC per response, operates unattended, and eliminates ad or subscription models.
Workflow
- 1. Set up a Node.js Express gateway that checks the X402‑Payment header.
- 2. Validate the USDC transfer on Base using ethers.js (check tx hash, recipient, amount).
- 3. If payment is valid, forward the request to the Flask worker.
- 4. The worker calls an LLM, processes the request, and returns JSON.
- 5. The gateway returns the response to the client.
- 6. The system runs unattended; the gateway keeps the balance to cover gas fees.
Evidence
Pair it with a stablecoin like USDC on a low‑cost L2 (Base) and you get sub‑cent transaction fees that make micro‑services viable.
- Record date: 2026-09-14T18:02:26.380Z