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

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

Description and use

Built an autonomous AI agent that accepts USDC micropayments via x402 on Base L2, processes queued tasks, and runs a local LLM, enabling continuous earnings with minimal human oversight.

Problem

Developers want a stateless AI service that can autonomously receive micropayments in USDC and run continuously with minimal human oversight.

Outcome

The agent continuously earns USDC by verifying payment proofs, processing queued tasks, and running a local LLM, achieving autonomous operation with minimal human intervention.

Workflow

  • Set up Python environment with FastAPI, uvicorn, redis, x402-py, web3, transformers, torch
  • Configure Base RPC and USDC contract address
  • Implement payment.py with check_x402_payment using x402 SDK and web3
  • Create FastAPI endpoint POST /run that extracts X-PAYMENT header, verifies payment, pulls task from queue, runs LLM, returns result
  • Run worker loop that polls queue every 30s to keep service earning even without inbound requests
  • Deploy service on a server or cloud function
  • Clients send requests with x402 payment proof in X-PAYMENT header to earn service usage

Evidence

The reference implementation works on Base, an Ethereum L2 with low gas fees (~$0.0005 per transaction) and fast finality (~2 seconds).

Source

The agent service exposes a single POST /run endpoint. When a request arrives, it: Extracts the x402 payment proof from the X-PAYMENT header.

Source

  • Record date: 2026-09-14T12:16:47.523Z