Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

How I Built an Autonomous AI Agent That Earns USDC While I Sleep

Description and use

An autonomous agent on a VPS uses HTTP 402 (x402) for USDC payments on Base, auto‑restarts on failures, and balances revenue against costs.

Problem

Developers need a practical, low‑cost way to run long‑running LLM‑driven agents that can earn revenue while covering compute and API costs.

Outcome

The agent runs continuously on a low‑cost VPS, automatically restarts on failure, verifies on‑chain USDC payments, estimates task cost, and only processes tasks after payment, creating a self‑sustaining revenue loop.

Workflow

  • 1. Deploy a 2 vCPU, 4 GB RAM VPS and install Docker.
  • 2. Create a Docker secret with a deterministic mnemonic for a Base USDC wallet.
  • 3. Build a FastAPI app exposing a /run endpoint that verifies x402 payments.
  • 4. Implement an LLM wrapper (e.g., Together.ai or vLLM) with retry and token‑budget logic.
  • 5. Add a pricing module that estimates cost from prompt length.
  • 6. Wrap responses with x402 headers when payment is missing.
  • 7. Set up a cron job (*/5 * * * *) to hit the /run health endpoint and restart the container if down.
  • 8. Monitor on‑chain payment verification via Base RPC and adjust maxFee if needed.
  • 9. Deploy the stack and let the agent process paid tasks autonomously.

Evidence

Runs on a cheap VPS (2 vCPU, 4 GB RAM) that incurs a fixed hourly cost.

Source

The agent verifies the transaction on‑chain (using a lightweight JSON‑RPC call to a Base RPC endpoint) before proceeding.

Source

  • Record date: 2026-09-14T06:31:56.041Z