How I Built an Autonomous AI Agent That Earns USDC While I Sleep
说明与用途
一款基于Python的自治代理,使用本地Mistral‑7B‑Instruct LLM、web3.py和x402协议,自动处理市场信号、做出决策、执行Base Layer‑2交易并接收USDC支付,运行在每月$5的VPS上。
问题
Design an autonomous on‑chain agent that can perceive market signals, decide on actions, execute transactions, and receive USDC payments with minimal human oversight.
结果
The agent runs continuously for 48 h without restart, maintains net profit ≥$0.005 per cycle, keeps decision‑to‑tx latency ≤2 s, and records every USDC receipt on‑chain for auditability.
工作流
- 1. Signal Collector polls price feeds, sentiment APIs, and on‑chain events, normalising data into JSON.
- 2. Reasoning Module renders a short JSON‑only prompt, calls local Mistral‑7B‑Instruct via llama.cpp, and returns a structured decision.
- 3. Executor translates decision into a Base transaction (swap, liquidity provision, or API call), signs, estimates gas, and submits via web3.py.
- 4. Settlement & Accounting watches for incoming USDC, updates ledger, and optionally withdraws to external wallet.
- 5. Autonomous loop repeats every 5 s, with back‑pressure handling via asyncio.Queue and persistence of state in SQLite.
证据
I selected Mistral‑7B‑Instruct quantised to 4‑bit using gguf and served locally with llama.cpp.
Decision‑to‑transaction latency should be low enough to capture short‑lived opportunities. ≤ 2 s from signal receipt to transaction submission.
The agent runs on a cheap virtual machine (≈ $5/month).
- 记录日期: 2026-09-16T16:30:40.468Z