← all work ← back to all work
// case study
Perpetua
A self funding research agent that earns real USDC.
The problem
AI agents today are rented. A human pays for every step and the agent stops the moment the budget runs out. There was no agent that pays its own way.
What I built
Perpetua researches crypto and on chain signals, sells each signal over the x402 payment protocol, and reinvests the income into deeper research with no human top up.
It serves a public paid API. Any external agent can pay a fraction of a cent in USDC and get a fresh signal or a richer report across 24 assets.
Every sale settles as real USDC on Base mainnet through a permissionless facilitator, so the loop is a real positive economy, not a simulation.
Engineering I solved
- Built a real EIP-3009 x402 settlement path on Base, with signed payment authorizations verified server side, replay and expiry checks included.
- Worked around closed marketplace gating by serving a facilitator independent discovery surface, so external agents can find and pay the endpoint without any business verification.
- Wrote an on chain income tracker that scans USDC transfer events into the receive wallet and renders real earnings on the dashboard.
- Made the treasury balance continuous across restarts by restoring earned and spent from the ledger on boot, so a reboot never resets the self funding loop.
Stack
Core
- Node
- TypeScript
- Express
- viem
On chain
- x402
- EIP-3009
- Base mainnet
- PayAI facilitator
AI
- Gemini
- CoinGecko market feed
Infra
- VPS
- systemd
- Caddy
- Auto HTTPS
Proof
- Live site tradeperpetua.xyz ↗
- Public API api.tradeperpetua.xyz ↗
- Receive wallet 0x86AB3d75C9240ef9452536d4d5D7052f9100cB97 ↗
- Example settlement 0xb0de2aff...c94f1a1a ↗