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

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

Description and use

Built an autonomous text summarisation service that automatically accepts USDC micropayments via x402 on Base L2 and processes requests without developer intervention.

Problem

Developers need a way to expose AI services that automatically collect micropayments and run continuously without manual intervention.

Outcome

The author demonstrates a low‑overhead, globally distributed AI service that automatically collects USDC micropayments and processes requests without manual oversight, achieving a self‑sustaining revenue stream.

Workflow

  • 1. Deploy an x402 Gateway Worker that reads the X402‑Payment header, verifies the transaction on Base via viem, and forwards valid requests to the Agent Worker.
  • 2. Deploy an Agent Worker that receives the request, extracts the text, runs a small ONNX summarisation model (or calls a hosted endpoint), and returns the summary.
  • 3. Bundle the ONNX model with the Agent Worker for zero‑cost inference or configure a hosted inference API for higher quality.
  • 4. Configure Cloudflare Workers environment variables (AGENT_WALLET, AGENT_WORKER_HOST).
  • 5. Clients send HTTP requests with the X402‑Payment header containing a signed USDC transfer to the Gateway.
  • 6. The Gateway validates the payment, forwards the request, and the Agent Worker processes and responds.
  • 7. The developer’s wallet accumulates USDC automatically.
  • 8. Monitor usage and scale Workers as needed.

Evidence

The x402 protocol satisfies #2: it lets an HTTP endpoint require a micropayment in USDC on the Base L2 before returning a response.

Source

I used a distilbert‑base‑uncased‑distilled‑squad‑style summariser converted to ONNX and bundled with the Worker (≈12 MB).

Source

  • Record date: 2026-09-14T12:15:57.693Z