VerseOS x402 Quickstart
VerseOS supports autonomous license purchases through x402 v2 on Solana.
The tested flow is:
Agent
↓ POST /v1/agent-licenses
VerseOS
↓ 402 + PAYMENT-REQUIRED
x402 client
↓ signs Solana payment
VerseOS/facilitator
↓ verifies + settles
VerseOS
↓ issues LIC-...
Agent
← 201 + PAYMENT-RESPONSECurrent environment: Solana devnet. Keep mainnet disabled until the VerseOS x402 fee/payout strategy is finalized.
Prerequisites
You need:
- Node.js 20+
- a VerseOS API key with
licenses:write - a throwaway Solana devnet wallet
- enough devnet USDC for the license
- enough devnet SOL for transaction fees if required by the client flow
Never commit or share the wallet private key.
1. Create a test project
cd C:\Users\YOU\Downloads
mkdir verseos-x402-test
cd verseos-x402-test
npm init -y2. Install dependencies
The tested package set is:
npm install @x402/core@2.19.0 @x402/svm@2.19.0 @x402/fetch @solana/kit @scure/baseDo not use --force or --legacy-peer-deps to bypass dependency resolution.
3. Create the buyer script
New-Item -ItemType File -Name "test-x402.mjs"Copy examples/x402-buyer.mjs from this documentation bundle into that file.
4. Set environment variables
$env:VERSEOS_API_KEY = "vos_live_YOUR_TEST_KEY"
$env:SVM_PRIVATE_KEY = "YOUR_THROWAWAY_DEVNET_BASE58_SECRET_KEY"SVM_PRIVATE_KEY is the base58-encoded Solana secret-key bytes expected by the test client. Do not paste it into logs, source files, tickets, or chat.
5. Run the purchase
node test-x402.mjsThe client will:
- POST the right ID to VerseOS;
- receive
402 Payment Required; - decode
PAYMENT-REQUIRED; - create and sign the Solana payment;
- retry the same request automatically;
- receive the issued VerseOS license.
Tested result
A successful private-beta test returned:
HTTP status: 201with a response shaped like:
{
"object": "agent_license",
"x402": true,
"quote_id": "XQ-A9B77CB8E9D7",
"payment": {
"status": "settled",
"network": "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
"transaction": "cCNAH2krhDGfEcCVamt6GuUYMmLwMfYao7nqXfrzxciLKPcjvBnhUpmpU8EmaaHS4Aqwd7pNbfuKpanZFHCGpgN"
},
"license": {
"public_id": "LIC-F40BD43BF6BC",
"status": "active"
},
"already_fulfilled": false
}The x402 settlement response also confirmed the payer, Solana transaction, and devnet network.
x402 quote semantics
Each request requires a unique Idempotency-Key.
The persisted quote binds:
- right;
- asset;
- price;
- creator payout wallet;
- license terms;
- network;
- x402 payment requirements.
Normal retry behavior reuses the stored quote rather than creating a second purchase.
Quote state:
pending -> settled -> fulfilledIf settlement succeeds but database fulfillment fails afterward, retry the same purchase with the same Idempotency-Key. VerseOS can resume from a settled quote instead of intentionally creating another payment.
Current x402 fee policy
VerseOS's normal checkout uses:
97.5% creator
2.5% VerseOSThe current x402 devnet MVP uses a single payTo address and therefore sends the full license price directly to the creator. VerseOS does not silently collect its normal 2.5% fee in this path.
Do not enable x402 mainnet until that production fee model is explicitly selected.