How I Built an Autonomous AI Agent That Earns USDC While I Sleep
Описание и применение
Создана статeless‑сервис на Cloudflare Workers, который принимает запросы к GPT‑4o, требует микроплатежи в USDC через x402 и автоматически переводит средства на кошелёк Base, обеспечивая пассивный доход.
Задача
Create a self‑paying AI service that charges a micro‑payment per call and automatically settles in USDC on Base.
Результат
A stateless, low‑latency AI endpoint that automatically earns USDC per call, with payments routed directly to a Base wallet and no custodial risk.
Рабочий процесс
- 1. Client sends JSON POST to Worker URL with question.
- 2. x402 middleware checks Payment header, verifies signed USDC on Base, returns 402 if invalid.
- 3. If payment valid, Worker instantiates Agent class and calls OpenAI chat completion.
- 4. Agent returns answer, Worker sends JSON response.
- 5. x402 forwards USDC to destination address; Worker never holds funds.
Доказательства
The result is a service that charges $0.01–$0.10 per call in USDC on the Base L2, with the earnings accruing to a wallet I control.
The Worker itself never holds funds; the x402 library forwards the USDC directly to the destination address encoded in the payment header.
- Дата записи: 2026-09-14T05:15:41.172Z