402gate 402gate DOCS
DOCS_V1.0

The Financial Layer of the Internet for AI Agents

402gate is an open payment infrastructure that enables instant, frictionless value exchange between data providers and autonomous AI agents.

With the explosion of LLMs (Large Language Models), the internet is shifting from a web read by humans to a web read by machines. Traditional business models—based on ads (which bots don't see) and credit card subscriptions (which bots don't have)—are becoming obsolete.

402gate solves this problem by implementing the x402 standard. We utilize the long-forgotten HTTP status code 402 Payment Required to create a native "language of money" that both servers and bots understand.

Why 402gate?

We are building infrastructure that turns the problem of uncontrolled scraping into a new revenue source.

Zero-Friction & Permissionless

In the traditional B2B model, API integration requires contracts, invoices, and API key exchanges. In 402gate, there is no registration, login, or forms.

  • > For You: Install the plugin/SDK and accept payments immediately.
  • > For the Bot: Payment is a single signed transaction. No clicking, no waiting.

From Scraping to Monetization

AI companies train their models on your data for free, burdening your servers. Blocking them (robots.txt, Cloudflare) is fighting a losing battle. 402gate allows you to set a gate: "Want my data? Pay 0.01 USDC". This turns a parasitic relationship into a business symbiosis.

Stable Settlements in USDC (Base)

You don't have to worry about crypto volatility. All transactions are settled in USDC (digital dollar) on the Base L2 network.

  • > Speed: Transaction finality in < 1 second.
  • > Cost: Network fees (Gas) are negligible (<$0.001) and covered by the buyer (Bot).
  • > Security: Non-Custodial Model. Funds go directly to your wallet (Self-Custody). We don't touch them.

Loyalty Program (Gate Points)

We believe in a co-creation economy. Every data provider processing transactions on the 402gate network receives Gate Points. This is an on-chain reputation system that will allow the community to decide the protocol's direction in the future.

Architecture: How it Works?

402gate acts as Middleware between your server and the end client. The entire process is automated and invisible to the user.

The diagram below shows the flow of a single request:

transaction_flow.log
01 >GET /api/premium-data
02 >Error: 402 Payment Required
.. x-payment-hash: missing
.. price: 0.01 USDC
03 >Initiating Payment...
.. >Tx: 0x7f...3a2b (Pending)
04 >Success! Payment Verified.
05 >GET /api/premium-data
.. Header: X-Payment-Hash: 0x7f...3a2b
06 >Data received: { "status": "ok", ... }
01
Request

Bot asks for a resource.

02
Offer (402)

Server blocks access and sends an "invoice" in JSON format (compliant with x402 spec).

03
Payment

Bot pays the invoice directly on the blockchain.

04
Verification

Bot retries the request with proof of payment (transaction hash).

05
Access

402gate verifies the payment in milliseconds and releases clean data.

Use Cases

Who is 402gate for?

Content Publishers / Bloggers

Charge micro-fees to AI bots (e.g., Perplexity, ChatGPT) for real-time access to your articles.

Market Data Providers

Sell crypto prices, stock quotes, or sports scores per request (Pay-per-request), instead of expensive monthly subscriptions.

AI Tools and APIs

Share your ML models or algorithms without building a user account system and Stripe integration.

Getting Started

Start Monetizing AI Agents in Minutes

Welcome to the 402gate documentation. Our platform offers a suite of tools (SDKs and plugins) that allow you to integrate native crypto payments into your existing infrastructure – whether you run a blog or are building an advanced API.

Choose the integration path that best fits your tech stack.

Choose Your Path

For Content Publishers (No-Code)

If you have a CMS-based site (WordPress) and want to protect your articles from free AI scraping.

Difficulty: Easy
Time: ~3 min
Reqs: WordPress 5.0+
Go to WordPress Integration →

For Data Scientists (Python)

If you create APIs, ML models, or data services in Python (FastAPI, Flask, Django). Decorator-based.

Difficulty: Medium
Time: ~10 min
Stack: Python 3.8+
Go to Python SDK →

For Web Developers (Node.js)

If you build modern web apps or APIs in JS/TS. Middleware for Express.js.

Difficulty: Medium
Time: ~10 min
Stack: Node.js 16+
Go to Node.js SDK →

What You Will Need

1.
Crypto Wallet (EVM)

Address to receive payments (e.g., Metamask, Coinbase Wallet, Phantom). We support Base Mainnet. You don't need any funds to start. The wallet is only for receiving payments.

2.
Environment

Admin access to WordPress OR Source code access to your API.

3.
Verifier API Address

During configuration, you will be asked for our verifier node address:

https://api.402gate.xyz

Getting Started FAQ

No. Using 402gate is completely free. We do not charge upfront fees or commissions during the Beta phase.
You can use curl or Postman to simulate AI bot behavior. Detailed instructions can be found in the specific SDK sections.
Yes. Modern AI agents (especially autonomous ones like AutoGPT or BabyAGI) are designed to recognize HTTP error codes. When they encounter 402 Payment Required along with payment instructions in JSON, they can automatically execute the transaction if they hold a wallet.

WordPress Plugin

Turn Your Content into Paid Data for AI

The official 402gate plugin allows you to instantly protect your WordPress posts and pages from free scraping by AI. It works in a "Plug & Play" model – requiring not a single line of code.

Prerequisites

Before you start, ensure you have:

  • > WordPress version 5.0 or newer.
  • > PHP version 7.4 or newer (standard on most hostings).
  • > EVM Wallet Address (e.g., from Metamask) to receive USDC payments on Base network.

Installation

Currently, the plugin is available via "Direct Download" (outside the official WordPress repository).

Step 1: Download

Download the latest version directly from our main page:

Download 402gate.zip

Step 2: Upload to Server

  1. Log in to your WordPress admin panel (yoursite.com/wp-admin).
  2. In the left menu, select PluginsAdd New.
  3. Click the Upload Plugin button at the top of the screen.
  4. Select the previously downloaded 402gate.zip file from your computer.
  5. Click Install Now.

Step 3: Activation

After successful installation, click Activate Plugin.

Configuration

This is the most important stage. Without proper configuration, the plugin won't know where to send the money.
Go to menu: Settings402gate.

1. Merchant Wallet Address

Paste your public wallet address here (starting with 0x...).

  • Payments in USDC from bots will be sent to this address.
  • Ensure you have access to this wallet on the Base network.

2. Price (USDC)

Set the price for one request (access to one article).

  • Recommended starting value: 0.01 (one cent).
  • You can enter any amount, e.g., 0.05 or 0.005.

3. Backend API URL

This field connects your site with the payment verification network. Enter exactly this address:

https://api.402gate.xyz

After filling, click Save Changes.

How it Works? (Blocking Logic)

The plugin works in the background and intelligently filters incoming traffic to your site.

Who enters? Plugin Reaction Effect
Human (Browser) Ignore Free Access (sees page normally)
Googlebot (SEO) Ignore (Whitelist) Free Access (page is indexed in Google)
AI Bot (GPTBot, Claude, curl) BLOCK Error 402 + Payment Request
Paying Bot Verification Payment Accepted + Clean Data Release (JSON)

Info: The plugin automatically detects popular Bot User-Agents (OpenAI, Anthropic, Google-Extended, Common Crawl) and developer tools (Python Requests, Axios, Postman).

Testing

Want to check if the plugin works without being a bot? We prepared a debug mode.

  1. Log out of WordPress (or open an Incognito tab).
  2. Go to any post on your blog.
  3. Append the suffix to the URL: ?bot=true
    Example: https://yoursite.com/my-article/?bot=true
  4. Press Enter.

Expected Result:

Instead of the article content, you should see a white screen with JSON code containing information:

"maxAmountRequired": "0.01"

...and your wallet address. This means 402gate is working correctly and protecting your content.

Python SDK

Monetize APIs and AI Models (FastAPI)

The official x402gate library for Python allows you to protect any API endpoint with a single decorator. It was designed with asynchronous frameworks like FastAPI (AI industry standard) in mind, but the architecture is open for adaptation.

Requirements

  • > Python 3.8+
  • > FastAPI (recommended) or Starlette
  • > EVM Wallet Address (Base Network)

Installation

The package is available in the official PyPI registry.

bash
$ pip install x402gate

Quick Start (FastAPI)

The simplest way to integrate is using the @protect decorator. It acts as a "gatekeeper" (middleware) that intercepts the request before it reaches your logic function.

1. Import and Configuration

main.py
from fastapi import FastAPI, Request
# Import the decorator from our library
from x402gate.core import protect 

app = FastAPI()

2. Protecting the Endpoint

Simply add the @protect decorator above the route handler function. You must provide the price and recipient wallet.

main.py
@app.get("/premium-forecast")
@protect(
    price="0.05", 
    wallet="0x1234567890123456789012345678901234567890" # Your public address
)
async def get_forecast(request: Request):
    # This code will execute ONLY if payment is verified.
    # Otherwise, x402gate returns HTTP 402 error.
    return {
        "status": "paid",
        "prediction": "BTC to 100k",
        "confidence": 0.98
    }

Note: Remember to include the request: Request argument in your function, as the decorator needs access to HTTP headers to verify the payment hash.

Configuration Parameters

The protect decorator accepts the following arguments:

Parameter Type Description Example
price str Price per request in USDC. "0.01"
wallet str Your Base (EVM) wallet address to receive funds. "0xAbC..."

How it Works Under the Hood?

When a user (or bot) sends a request to a protected endpoint:

1.
Inspection

SDK checks for the presence of the X-Payment-Hash header.

2.
Block (402)

If the header is missing, SDK interrupts processing and returns a JSON response with code 402, containing payTo (Your wallet) and maxAmountRequired (Price).

3.
Verification

If the header is present, SDK connects to the verification node api.402gate.xyz to check the transaction status on Base blockchain.

4.
Access

If verification is successful, your get_forecast function is executed, and data is returned to the client.

Client Example (How to Test?)

To test your API as a client (bot), you can use curl:

Step 1: Check Price (Hit the Wall)

bash
$ curl -v http://localhost:8000/premium-forecast
# You get 402 Payment Required + JSON with payment data

Step 2: Access with Payment (Simulation)

After making a payment on the blockchain, the bot sends the request again with the transaction hash:

bash
$ curl -v -H "X-Payment-Hash: 0x_TX_HASH_FROM_BASE..." http://localhost:8000/premium-forecast
# You get 200 OK + Data

Node.js SDK

Monetize APIs and Microservices (Express.js)

For the JavaScript/TypeScript environment, we prepared a lightweight middleware that integrates with popular server frameworks (like Express.js). This allows you to "cut off" access to any route and require payment before executing business logic.

Requirements

  • > Node.js v16+
  • > Express.js (or connect-style middleware compatible framework)
  • > EVM Wallet Address (Base Network)

Installation

The package is available in the NPM registry.

bash
$ npm install x402gate

Quick Start (Express.js)

The SDK works as a middleware function. It intercepts the request object, checks payment status, and decides whether to pass traffic through (next()) or return a 402 error.

1. Import and Configuration

server.js
const express = require('express');
const x402gate = require('x402gate');

const app = express();

// Payment gateway configuration
const paywall = x402gate({
    wallet: "0x1234567890123456789012345678901234567890", // Your wallet address
    price: "0.05" // Price in USDC
});

2. Protecting Routes

You can use the paywall constant as the second argument in the route definition.

server.js
// This route is free
app.get('/', (req, res) => {
    res.send('Hello World!');
});

// This route requires 0.05 USDC payment
// Middleware 'paywall' checks payment BEFORE this code runs
app.get('/api/secret-data', paywall, (req, res) => {
    res.json({
        status: "success",
        data: "Here is premium data your bot paid for.",
        timestamp: new Date()
    });
});

app.listen(3000, () => {
    console.log('Server running on port 3000');
});

Configuration Options

Function x402gate(options) accepts an object with the following parameters:

Parameter Type Required Description
wallet string Yes Your public address on Base network (0x...) to receive funds.
price string Yes Amount in USDC (e.g. "0.01"). Remember to pass it as a string.

Error Handling

Middleware automatically handles typical error scenarios, returning appropriate HTTP codes, so you don't need to write try/catch in your controller.

402
Payment Required

When payment header is missing (returns JSON with payment instructions).

402
Payment Invalid

When submitted transaction hash is invalid or funds didn't reach your wallet.

500
Internal Server Error

When there is a problem connecting to the verification node.

Testing (Client-Side)

To test a protected endpoint, you can use curl or create a simple JS client.

Step 1: Request without payment

bash
$ curl -v http://localhost:3000/api/secret-data
# Expected result: HTTP 402 + JSON { "payTo": "...", "price": "0.05" }

Step 2: Request with payment

After executing transaction on blockchain, client must add x-payment-hash header.

bash
$ curl -v -H "x-payment-hash: 0x_YOUR_TX_HASH..." http://localhost:3000/api/secret-data
# Expected result: HTTP 200 + Your JSON data

Gate Points & Economics

Economic Model & Loyalty Program

402gate is not just technology, it's a new economic model for the internet. In this section, we explain how money (USDC) flows and how our incentive system (Gate Points) works.

Payment Model (Peer-to-Peer)

Our architecture is based on Zero-Trust and Non-Custodial principles. This means that as a platform, we never touch your money.

Fund Flow

1.
Buyer (AI Bot)

Signs the transaction with its private key.

2.
Network (Base Blockchain)

Transfers funds directly from the bot's wallet to your wallet.

3.
Seller (You)

You receive 100% of the transaction amount in USDC.

Transaction Costs (Gas Fees)

A common question is: "Will network fees eat up my profit?"

Answer: No.

  • * Network: We use Base L2 (Ethereum Layer 2), where costs are minimal.
  • * Sender Principle: In the crypto world, the gas fee is always paid by the sender (Bot).
  • * Your Margin: If you set the price to 0.01 USDC, you receive exactly 0.010000 USDC.

Gate Points

Gate Points is an internal reputation and loyalty system designed to reward Data Providers who actively co-create the 402gate network during the Beta phase.

How to earn points?

Points are accrued automatically by our verification node (Oracle) after every successful on-chain transaction.

Action Reward
Handling a paid request 10 Points
Payment verification Automatic

Example: If your site handles 100 requests from AI bots in a day, your wallet receives 1.00 USDC (earnings) and 1000 Gate Points (reputation).

Purpose of Points

Gate Points serve to:

  1. Contribution Measurement: We identify the most valuable nodes in the network (e.g., those with high uptime and unique data).
  2. Reputation: In the future, points may unlock premium features (e.g., lower fees in SaaS model) or influence voting weight in protocol governance.

Checking Points Balance

Since points are stored off-chain (in our Supabase database), you won't see them in MetaMask. You can check your balance via our public API:

http
GET https://api.402gate.xyz/points/{YOUR_WALLET_ADDRESS}
Response:
{
  "wallet": "0x123...",
  "points": 4500,
  "last_updated": "2025-10-24T12:00:00Z"
}

Economic FAQ

Currently NO. Gate Points are database points (like airline loyalty points). They cannot be bought, sold, or transferred. They are strictly tied to the wallet address that earned them.
We focus on building the product and utility. If we decide to decentralize the protocol via a governance token in the future, the history of Gate Points will be a key factor in distribution (Airdrop) to the community.
In the current phase (Public Beta), commission is 0%. The entire revenue goes to you. In the future, we may introduce optional commission models for advanced features (e.g., Smart Contract Splitter).
```