DEV Community

Cover image for Stop Blocking AI Bots. Charge Them. (I built a Payment Protocol in Node.js)
ankitx1357-boop
ankitx1357-boop

Posted on

Stop Blocking AI Bots. Charge Them. (I built a Payment Protocol in Node.js)

javascript #node #showdev #ai ## The Problem

Everyone is scrambling to block AI scrapers (GPT-5, Claude, Gemini) from reading their data. They are using CAPTCHAs, firewalls, and robots.txt.

I realized this is a losing battle. Instead of blocking them, why not tax them?

The Solution: Tollgate

I spent the last 24 hours building Tollgateβ€”a sovereign middleware for the Agentic Web.

Instead of a 403 Forbidden, my server returns a 402 Payment Required.
If the Agent pays the toll (via a micro-transaction), they get a JWT and access to clean, structured JSON data.

The Architecture

I deployed the live node on Render to test the theory.

  • Backend: Node.js + Express
  • Auth: JSON Web Tokens (JWT)
  • Asset: Real-time Bitcoin Price Oracle (via CoinDesk API)
  • Pricing: Hardcoded at $1.00 per request.

[Image of API Gateway architecture flow]

The Code

Here is the client-side script I wrote to verify the transaction. It pays the bank, gets the token, and unlocks the vault automatically:


javascript
// verify.js - The Client
const axios = require('axios');
const BASE_URL = "[https://tollgate-live-1.onrender.com](https://tollgate-live-1.onrender.com)"; 

async function verifyTheGold() {
    // 1. Pay $1.00
    const payResponse = await axios.post(`${BASE_URL}/pay`, {
        agent_id: "DevTo-Reader",
        amount: 1.00
    });
    const token = payResponse.data.access_token;

    // 2. Access Data
    const dataResponse = await axios.get(`${BASE_URL}/premium-data`, {
        headers: { 'Authorization': token }
    });

    console.log("πŸ’° BTC Price:", dataResponse.data.price);
}                                                                                     Try the Live Demo
You can hit the API right now. It's running 24/7 on the cloud.

πŸ‘‰ Live Node: https://tollgate-live-1.onrender.com

I'm an 18-year-old developer looking for feedback on this architecture. Does the Agentic Web need a native currency layer? Let me know in the comments.


### **Step 3: Publish**
Hit the **Publish** button.

**Crucial Last Step:**
Once it is live, **copy the link to your post and paste it here.**
I want to confirm it looks good. Go! πŸš€
Enter fullscreen mode Exit fullscreen mode

Top comments (0)