What x402 is
x402 puts HTTP's 402 Payment Required code to work. An API answers a request with 402 and its price, the client pays in USDC on Solana, and retries with proof of payment.
No account, no API key and no subscription: each request pays for itself. It's an open standard, and the spec is at x402.org.
The catch is that a normal x402 payment comes from your wallet, so every API you call learns your address, and anyone can see what you're paying for. Unlisted pays from your private balance instead.
privateFetchComing soon
privateFetch is a drop-in for fetch. Call it the way you call fetch, with a spending cap. If the API answers 402, it pays from your private balance through the relay and returns the API's real response. If it doesn't, it's an ordinary request.
import { privateFetch } from "unlisted";
const res = await privateFetch("https://api.example.com/forecast", {
maxUsd: 0.05,
});It will be published to npm as unlisted. It isn't published yet, and the names and options here may change before it is. Until then you can paste an x402 link into the app and pay it there.
The relay flow
1. The API answers 402
Your request comes back as 402 Payment Required, with the price in USDC and the address to pay, under the exact scheme.
2. You pay the relay, privately
Your private account sends that exact amount to the relay's private account, inside the Ring. The amount is encrypted. The two addresses are visible, like any private send.
3. The relay pays the API
The relay sees your payment land, pays the API from its own wallet, and retries your request with proof of payment.
4. You get the response
The API's real response comes back to your code. The payment stays in your history, encrypted like the rest.
Who sees what
The API
A paid request from the relay's wallet. Not your wallet, and not your private account.
The chain
A private send from your private account to the relay, amount hidden. Then a public USDC payment from the relay to the API.
Unlisted's relay
Your private account, the API you called and the amount, for the seconds it takes to handle the payment.
Anyone watching closely
Timing can connect your private send to the relay's public payment a moment later. It keeps your wallet from the API; it isn't perfect unlinkability.
Limits
Network
USDC on Solana mainnet only.
Scheme
exact only: the API names one price, and that's what gets paid.
Price cap
maxUsd is the most one call may pay. Above it, the call fails instead of paying.
Fee
The API's price. Unlisted's relay fee is 0 for now.
Balance
You need the price in USDC in your private balance. SOL isn't used for x402.
The relay holds your payment only between steps 2 and 3. Read the risks before you give an agent a balance to spend.
Open app