Back to browse
GitHub Repository

Caddy middleware that charges AI crawlers USDC via the x402 protocol

3 starsGo

Caddy plugin that charges AI crawlers real USDC to access your site

by paolobietolini·Feb 27, 2026·1 point·2 comments

AI Analysis

●●●BangerZero to OneBold BetWizardry

Makes AI crawlers actually pay in USDC when x402.org facilitator adoption scales.

Strengths
  • Novel protocol-first approach: x402 is standardized (Coinbase-backed), not a proprietary paywall.
  • Direct wallet-to-wallet settlement on-chain; no middleman escrow or API key dependency.
  • Practical implementation: ships today, running live, zero crypto knowledge required for setup.
Weaknesses
  • Adoption blocker: GPTBot, ClaudeBot don't yet support x402 payments, so crawlers just get 402'd.
  • Relies entirely on x402.org facilitator staying operational; protocol maturity unproven at scale.
Target Audience

Website owners concerned about AI scraping; Caddy users wanting to monetize crawler access.

Similar To

Cloudflare Workers with paid tier verification · robots.txt enforcement tooling · PaymentRequest API integrations

Post Description

Hello, I built a Caddy middleware that implements the x402 protocol (by Coinbase) to charge AI crawlers real money for content access.

When GPTBot, ClaudeBot, or any known AI crawler hits your site, it gets an HTTP 402 with payment requirements. If it pays (USDC on Base), it gets the content. If not, it gets nothing.

Normal users are never affected.

How it works: - Crawler detected by User-Agent → 402 response with price and wallet address

- Crawler signs a USDC payment (EIP-3009) and retries with X-PAYMENT header

- Plugin forwards to x402.org facilitator → on-chain settlement on Base

- USDC goes directly from crawler's wallet to yours

- Content served

Configuration is a few lines in the Caddyfile:

x402 { pay_to 0xYOUR_WALLET price 0.05 network base exempt /robots.txt }

It's running on my site right now. No payments yet since most crawlers don't support x402, but they get blocked with a proper 402 instead of getting free content. When they do adopt it, the infrastructure is ready.

Built with pure Go (no CGo), SQLite audit trail, Cloudflare-compatible headers.

Similar Projects