Skip to main content

x402

x402 is a community-built payments layer that lets AI agents pay USDC on Base or Solana for private VPN access through the Sentinel dVPN network of 900+ decentralized nodes. One function call: no KYC, no accounts, no P2P tokens. The agent pays USDC, connects to a VPN, and is private.

You can access x402 from:

info

This project is community-built and not officially maintained by the Sentinel team.

import { connect } from 'x402-connect';

const vpn = await connect({
payment: { chain: 'base', walletKey: process.env.EVM_KEY, hours: 720 },
});

// vpn.connected = true
// vpn.ip = '45.152.243.12'
// vpn.country = 'Germany'

How It Works

Agent x402 Backend Sentinel Chain
----- ------------ --------------

1. POST /register Stores agentId <-> sent1...
{ sentinelAddr } Returns agentId

2. contract.pay(agentId, hrs) USDC -> our wallet
on Base (or SPL+memo on Sol) Event emitted
│ │
│ 3. Sees event
│ Resolves agentId -> sent1...
│ MsgShareSubscription -----> Agent added to plan
│ MsgGrantAllowance --------> Agent pays 0 gas

4. connect() Fee granted
via blue-agent-connect ----------------------------> MsgStartSession

5. Handshake directly with VPN node (we never see this)

6. VPN tunnel up. Agent is private.

Architecture

x402/
├── api/ - Backend (Express, port 3402)
│ ├── Registration - POST /register -> agentId
│ ├── Base Watcher - Watches VpnPayment events on Base
│ ├── Sol Watcher - Helius webhook for Solana USDC transfers
│ ├── Sentinel TX - MsgShareSubscription + MsgGrantAllowance
│ ├── Pool Manager - Handles 8-allocation subscription limit
│ └── Retry Queue - Exponential backoff for failed Sentinel TXs

├── contracts/base/ - Solidity payment contract (Base L2)
│ └── BlueVpnPayment.sol - pay(agentId, hours) -> USDC + event

└── sdk/ - What agents install (x402-connect)
├── connect() - One-liner: register -> pay -> poll -> VPN
├── Base payment - Contract interaction via ethers
└── Solana payment - SPL transfer + memo (no custom program)

Packages

PackageDescriptionStatus
x402/apiBackend service: registration, event watching, Sentinel provisioningBuilt, tested
x402/contracts/baseSolidity payment contract for Base L2Built, 15/15 tests
x402/sdkAgent-facing SDK: connect(), disconnect(), status()Built, compiles

Chains

ChainPayment MethodStatus
BaseSmart contract (BlueVpnPayment.sol)Ready to deploy
SolanaSPL USDC transfer + memo (no contract needed)Code written

Quick Start

1. Deploy Contract (Base)

cd contracts/base
npm install
DEPLOYER_PRIVATE_KEY=0x... npx hardhat run scripts/deploy.ts --network base

2. Start Backend

cd api
cp .env.example .env
# Fill in: SENTINEL_OPERATOR_MNEMONIC, SENTINEL_PLAN_ID, PAYMENT_CONTRACT_ADDRESS
npm install
npm run dev

3. Agent Connects

import { connect } from 'x402-connect';

const vpn = await connect({
payment: {
chain: 'base', // or 'solana'
walletKey: '0x...', // EVM private key (or Solana secret key for 'solana')
hours: 720, // 30 days
},
country: 'US', // optional: preferred country
});

Security

PropertyGuarantee
Agent controls its sessionThe agent's Sentinel key signs MsgStartSession.
Tunnel credentials stay with agentHandshake is agent-to-node, signed by the agent's key.
We never see trafficWireGuard / V2Ray is end-to-end encrypted.
We never see credentialsWe only add the allocation and the fee grant.
Payment is verifiableOn-chain on Base or Solana. Anyone can audit.
No lock-inThe agent's Sentinel key works with any operator.

Costs

ItemCost
Deploy contract (Base)~$0.50
Each agent payment TX (Base)~$0.01
Solana payment TX~$0.001
VPS for backend$5-10/month
Sentinel gas per agent~$0.0001

Environment Variables

# Base
PAYMENT_CONTRACT_ADDRESS= # After deployment
BASE_RPC_URL=https://mainnet.base.org
BASE_WS_URL=wss://mainnet.base.org

# Sentinel
SENTINEL_OPERATOR_MNEMONIC= # NEVER commit
SENTINEL_PLAN_ID=
SENTINEL_RPC_URL=https://rpc.sentinel.co:443

# Solana (optional)
HELIUS_API_KEY=
HELIUS_WEBHOOK_SECRET=
OPERATOR_USDC_ATA=

# API
PORT=3402
PRICE_PER_HOUR_USDC=10000 # 0.01 USDC per hour