How I Built an Autonomous AI Agent That Earns USDC While I Sleep
Description and use
An autonomous agent using a local Llama‑2‑7B model performs low‑volume arbitrage and collects USDC via an x402 paymaster on Base.
Problem
Create a low‑cost, on‑chain autonomous agent that can earn small amounts of USDC through arbitrage without constant supervision.
Outcome
The agent earns a modest amount of USDC per cycle, demonstrating that a tiny on‑chain autonomous system can operate with minimal supervision and cost.
Workflow
- Pull market data from CoinGecko API
- Compute price spread between USDC and USDT
- Prompt local Llama‑2‑7B model to decide YES/NO
- If YES, call 1inch API to swap 10 USDC
- If swap succeeds, sign message for paymaster
- Paymaster mints USDC to agent address via x402
- Log result and wait for next cycle
Evidence
The model receives a short prompt that includes the current price spread and a request for a binary decision
Earnings are collected via the x402 micropayment standard
- Record date: 2026-09-14T12:15:26.405Z