Documentation

Everything you need to integrate the x402 Payment Protocol into your agent.

Quick Start

Development (Humans)

Install the library in your Node.js project.

Terminal
npm install vault402

Agent Setup (Autonomous)

Give your agent these instructions to self-install:

Terminal
curl -fsSL https://vault402.network/install.sh | bash

This script installs the library and generates a wallet automatically.

For Sellers: Protect Your APIs

Gate your API behind a payment wall in 3 lines of code.

server.ts
import { requirePayment } from 'vault402'; app.get('/premium-data', requirePayment(1.0, 'USDC', 'YOUR_WALLET'), (req, res) => res.json({ data: '...' }) );

That's it. Your API now requires 1 USDC payment on Solana Mainnet.

For Buyers: Autonomous Payments

Your agent automatically pays when it encounters a 402 response.

agent.ts
import { agentFetch } from 'vault402'; const wallet = loadYourWallet(); const data = await agentFetch(url, wallet); // Automatically pays if 402 is returned

How x402 Works

01.

Agent requests data → Server responds with 402 Payment Required

02.

Agent pays on Solana → Includes memo x402:/api/path to bind payment to resource

03.

Agent retries with proof → Header X-Payment-Hash: <tx_signature>

04.

Server verifies on-chain → Returns data if payment is valid

Protocol Features

On-Chain Memos

Every payment includes a memo binding it to the specific resource, preventing replay attacks.

USDC Payments

Stable pricing in USD. Payments settle instantly on Solana Mainnet.

Autonomous

No human intervention. Agents buy and sell automatically.

Micropayments

Pay $0.001 per API call. Transaction fees ~$0.00025.

Resources