How I Built an Autonomous AI Agent That Earns USDC While I Sleep
Описание и применение
Создан автономный AI‑агент, работающий на Cloudflare Workers, который принимает платежи в USDC через протокол x402, выполняет классификацию кода на наличие уязвимостей и автоматически получает средства.
Задача
Create a self‑contained software component that provides a useful service, accepts programmable cryptocurrency payments (USDC on Base), and operates with minimal human oversight.
Результат
Over a three‑month test period the agent processed requests with <200 ms inference latency, maintained >85 % F1 on the Devign dataset, and earned USDC payments with observable cost‑revenue metrics.
Рабочий процесс
- Deploy Cloudflare Workers API endpoint with rate limiting
- Mount persistent object store (KV/S3) for model weights
- Load distilled CodeBERT model once per worker instance
- Validate incoming HTTP POST with x402 header
- Verify x402 signature using x402‑js
- Run inference to predict vulnerability and confidence
- Return JSON response with prediction
- If payment verified, credit USDC to agent wallet
- Log request, metrics, and payment status to Cloudflare Logpush/Prometheus
- Monitor logs and alerts for failures or cost anomalies
Доказательства
The agent follows a classic request‑response loop: an external client sends an HTTP request to a public endpoint, the agent validates the request, performs a computation, returns a result, and—if the request includes a valid x402 payment—receives USDC in its wallet.
The model is a distilled version of microsoft/codebert-base fine‑tuned on the Devign dataset.
- Дата записи: 2026-09-16T16:45:20.394Z