DEV Community

ankitx1357-boop
ankitx1357-boop

Posted on

How I built a Sovereign Payment Node for AI Agents in 24 Hours

Everyone is trying to block AI scrapers. I decided to tax them. I built Tollgate, a Node.js middleware that forces AI Agents to pay $1.00 USD to access premium data. The Stack:

Node.js & Express

JWT for authentication

CoinDesk API for data

Render for hosting const axios = require('axios');

// ๐Ÿ”ด PASTE YOUR RENDER URL HERE (No slash at the end)
const BASE_URL = "https://tollgate-live-1.onrender.com";

async function verifyTheGold() {
console.log(๐ŸŽฏ Target: ${"https://tollgate-live-1.onrender.com"});

try {
    // STEP 1: Pay $1.00
    console.log("1. ๐Ÿ’ธ Sending $1.00 Premium Payment...");

    const payResponse = await axios.post(`${BASE_URL}/pay`, {
        agent_id: "Big-Spender-Bot",
        amount: 1.00  // <--- UPDATED PRICE
    });

    const token = payResponse.data.access_token;
    console.log("   โœ… Payment Accepted! Token received.");

    // STEP 2: Get Data
    console.log("2. ๐Ÿ”“ Accessing Premium Vault...");

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

    // STEP 3: Result
    console.log("\n   ๐ŸŽ‰ SUCCESS! DATA RECEIVED:");
    console.log("   ========================================");
    console.log("   ITEM:  " + goldResponse.data.item);
    console.log("   PRICE: " + goldResponse.data.price);
    console.log("   ========================================");

} catch (error) {
    console.error("\nโŒ FAILED.");
    if (error.response) {
         console.error("   Server Message:", error.response.data);
    } else {
         console.error("   Error:", error.message);
    }
}
Enter fullscreen mode Exit fullscreen mode

}

verifyTheGold(); Live Demo: You can try hitting the API here: https://tollgate-live-1.onrender.com

Let me know what you think of this architecture!

Tags: #javascript, #showdev, #ai, #node.

Top comments (0)