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.
npm install vault402Agent Setup (Autonomous)
Give your agent these instructions to self-install:
curl -fsSL https://vault402.network/install.sh | bashThis 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.
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.
import { agentFetch } from 'vault402';
const wallet = loadYourWallet();
const data = await agentFetch(url, wallet);
// Automatically pays if 402 is returnedHow x402 Works
Agent requests data → Server responds with 402 Payment Required
Agent pays on Solana → Includes memo x402:/api/path to bind payment to resource
Agent retries with proof → Header X-Payment-Hash: <tx_signature>
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.