Charge AI bots that crawl your site

agent402-tollbooth is an open-source, self-hostable pay-per-crawl gate. Put it in front of a Node site and AI crawlers pay per request to read your content: in USDC on Base or another EVM chain your x402 facilitator settles, over MPP on the same 402, or by solving a proof-of-work. People browse free, and payments settle straight to your wallet with nothing taken. 30-min walkthrough →

1 · Configure

Tip: start with observe: true for a day. A request the gate would charge passes with an X-Tollbooth-Observed: would-charge header and is counted in gate.stats().wouldCharge, so you see what is crawling you before you charge anyone.

2 · Install

npm install agent402-tollbooth express @x402/express @x402/core @x402/evm

Set X402_FACILITATOR_URL to an x402 facilitator that settles USDC on Base, then start your server normally. The x402 middleware is what collects USDC, and with it the same 402 also carries MPP challenges; without it the gate still answers crawlers with a 402 and lets through any that solve the proof-of-work, but no payment can be accepted. gate.stats() returns the counts: requests, charged, and paid by x402, MPP or proof-of-work.

The reverse proxy (npx agent402-tollbooth) and the Cloudflare Worker also serve a dashboard at /__tollbooth with JSON at /__tollbooth/stats. On the proxy, TOLLBOOTH_ADMIN_TOKEN gates both and is read from an Authorization: Bearer header; on the Worker, TOLLBOOTH_STATS_TOKEN gates the JSON the same way.

3 · Roll out safely

Phase 1 · 24h

observe: true

Nothing is blocked. gate.stats() counts what you would charge.

Phase 2 · ongoing

mode: "bots"

Known AI crawler user-agents (the default list in bots.js) get a 402. People pass.

Phase 3 · optional

mode: "strict" / "all"

strict charges anything that is not a real browser; all charges every client, people included, except what your free() predicate allows. Proof-of-work keeps the page reachable without a wallet; adaptive: true raises its difficulty under load.

Not running Express?

More