For AI agents editing this repo. Read this before making changes.
src/
├── service.ts ← EDIT THIS (your service logic, pricing, description)
├── scrapers/
│ └── maps-scraper.ts ← Reference implementation (Google Maps scraping)
├── types/
│ └── index.ts ← TypeScript interfaces for your service
├── utils/
│ └── helpers.ts ← Reusable extraction helper functions
├── index.ts ← DON'T EDIT (server, CORS, rate limiting, discovery)
├── payment.ts ← DON'T EDIT (x402 USDC verification on Solana + Base)
└── proxy.ts ← DON'T EDIT (proxy credentials + fetch with retry)
The repo ships with a working reference implementation — a Google Maps Lead Generator built by @aliraza556.
Endpoints:
GET /api/run?query=plumbers&location=Austin+TX&limit=20— Search businessesGET /api/details?placeId=<google_place_id>— Get detailed business infoGET /health— Health checkGET /— Service discovery JSON
- SERVICE_NAME — Short identifier for your service
- PRICE_USDC — Price per request in dollars (0.005 = half a cent)
- DESCRIPTION — One-line description for AI agents
- OUTPUT_SCHEMA — Describes your input/output contract (AI agents read this)
- The /run handler — Your actual business logic
serviceRouter.get('/run', async (c) => {
// 1. Payment check (extractPayment → build402Response if null)
// 2. Payment verification (verifyPayment → reject if invalid)
// 3. Input validation (check query params, reject if bad)
// 4. Your logic (use proxyFetch for web requests)
// 5. Return JSON result with payment confirmation
});getProxy()— Returns proxy config from .envproxyFetch(url, options?)— Fetch through mobile proxy with retry (2 retries, 30s timeout)
extractPayment(c)— Extract tx hash + network from request headersverifyPayment(payment, wallet, amount)— Verify USDC on-chain (Solana or Base)build402Response(resource, desc, price, wallet, schema)— Standard 402 JSON
Copy .env.example to .env:
- WALLET_ADDRESS — Your Solana wallet (required)
- WALLET_ADDRESS_BASE — Your Base wallet (optional, defaults to WALLET_ADDRESS)
- PROXY_HOST/PORT/USER/PASS — Mobile proxy credentials
- PORT — Server port (default 3000)
- RATE_LIMIT — Max requests per IP per minute (default 60)
- SOLANA_RPC_URL — Custom Solana RPC (optional)
- BASE_RPC_URL — Custom Base RPC (optional)
bun install # Install dependencies
bun run dev # Development with hot reload
bun run start # Production
bun run typecheck # Type checkingcurl localhost:3000/health # → 200 healthy
curl localhost:3000/ # → 200 service discovery JSON
curl "localhost:3000/api/run?query=plumbers&location=Austin+TX" # → 402 payment required (correct!)The 402 response contains everything an AI agent needs to make a payment and retry.
# Docker
docker build -t my-service .
docker run -p 3000:3000 --env-file .env my-service
# Direct
bun install --production && bun run start- Payment verification is ON by default (Solana + Base RPCs)
- SSRF protection blocks private/internal URLs
- Rate limiting is per-IP (configurable via RATE_LIMIT env var)
- See SECURITY.md for production hardening checklist