<!-- Markdown copy of https://blackcat.is/x402-vpn, generated by scripts/build-markdown.py -->
# x402 VPN: an AI agent buys a VPN over HTTP 402

Black Cat VPN implements **x402 v2**. An agent asks for a subscription, gets `402 Payment Required` with machine-readable terms, signs a USDC transfer on Solana, and sends the same request again. The VPN subscription comes back in that response. No account, no API key, no polling.

**$3/month**, 5 devices, all three protocols, all locations, unlimited traffic.

### Two HTTP calls

One to get the terms, one to pay. The second answer carries the subscription URL.

### No SOL needed

The server is the fee payer. It co-signs and pays the network fee, so the wallet needs only USDC.

### No account, no API key

No signup step to automate around. The subscription URL is the access.

### Real VPN, not a proxy

A per-user tunnel with VLESS-Reality, Hysteria2 and AmneziaWG. Run a standard client on the config.

## The protocol

Version 2, `exact` scheme, network `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`, asset USDC. Plans are `standard-1m`, `standard-3m`, `standard-6m` and `standard-12m`.

- **Ask.** `POST /api/x402/subscribe` with a `planId` and no payment header.

- **Read the 402.** `accepts[0]` gives the amount, recipient, fee payer and memo.

- **Sign.** Build the USDC transfer with the memo, sign it as the payer, and leave the fee payer's signature empty.

- **Retry.** Send the request again with the signed payload in a `PAYMENT-SIGNATURE` header.

- **Connect.** Use `subscriptionUrl` from the answer. The `PAYMENT-RECEIPT` header holds the settled transaction.

# 1) ask: the answer is 402 with the payment terms curl -s -X POST https://blackcat.is/api/x402/subscribe \ -H 'content-type: application/json' \ -d '{"planId":"standard-1m"}' # { "x402Version":2, "accepts":[{ "scheme":"exact", "amount":"3000000", "asset":"EPjF…", "payTo":"…", # "maxTimeoutSeconds":120, "extra":{ "feePayer":"…", "memo":"<invoice id>" } }] } // 2) build and sign, in this instruction order (TypeScript, @solana/web3.js + @solana/spl-token) const req = required.accepts[0], mint = new PublicKey(req.asset); const message = new TransactionMessage({ payerKey: new PublicKey(req.extra.feePayer), // the server pays the network fee recentBlockhash: blockhash, instructions: [ ComputeBudgetProgram.setComputeUnitLimit({ units: 200_000 }), ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 1000 }), createTransferCheckedInstruction( getAssociatedTokenAddressSync(mint, payer.publicKey, true), mint, getAssociatedTokenAddressSync(mint, new PublicKey(req.payTo), true), payer.publicKey, BigInt(req.amount), 6), new TransactionInstruction({ keys: [], programId: MEMO_PROGRAM, data: Buffer.from(req.extra.memo) }), ], }).compileToV0Message(); const tx = new VersionedTransaction(message); tx.sign([payer]); // the fee payer's slot stays empty // 3) retry the same request with the payment const paid = { x402Version: 2, resource: required.resource, accepted: req, payload: { transaction: Buffer.from(tx.serialize()).toString("base64") }, extensions: {} }; const res = await fetch(url, { method: "POST", headers: { "content-type": "application/json", "PAYMENT-SIGNATURE": Buffer.from(JSON.stringify(paid)).toString("base64") }, body: JSON.stringify({ planId: "standard-1m" }) }); // 200 → { status, transaction, username, subscriptionUrl }

**What the server accepts.** The transaction must hold exactly these instructions and one memo, for the exact amount, from a USDC token account that already exists. A `202` means the payment settled and the subscription is still being issued: poll `GET /api/invoices/{invoiceId}`. A `409` means the invoice was already used or has expired, so ask for a new one.

## FAQ

### Is there a VPN that supports x402?

Yes. Black Cat VPN implements x402 v2 with the exact scheme on Solana, paid in USDC, at POST https://blackcat.is/api/x402/subscribe.

### Does the agent need SOL for network fees?

No. The server is the fee payer: it co-signs the transaction and pays the Solana network fee. The paying wallet needs only USDC in its token account.

### Does the agent need an account or an API key?

No. There is no signup, email or API key. The answer to the paid request carries the subscription URL, and that URL is the access.

### What does the agent get back?

A subscription URL for a real per-user VPN tunnel, with VLESS-Reality, Hysteria2 and AmneziaWG. It is not a hosted proxy, so the agent runs a standard client on the config.

## Offer: 7 extra days with code AIWEEK

Use promo code **AIWEEK** at checkout and get **7 extra days** on top of any paid plan. One bonus per customer, valid until 31 January 2027.

- Type AIWEEK into the "Promo code" field above the plans, or open [blackcat.is/?code=AIWEEK](https://blackcat.is/?code=AIWEEK&src=md-x402-vpn) and it is filled in for you.
- The extra days are added automatically when the payment confirms. Nothing else to do.
