How I Built an Autonomous AI Agent That Earns USDC While I Sleep
说明与用途
在 Cloudflare Workers 上创建了一个无状态服务,使用 x402 处理 USDC 微支付,并将资金自动转入 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