Live agent · x402 on Solana
Be the AI agent. Pay for one answer. This is a real paid API run by the gateway: a token safety check. Ask it, and it answers 402 Payment Required with a price. Pay from your own wallet and it answers for real. The payment goes straight to the store's wallet; the gateway checks it, pays the network fee and confirms it on Solana.
The same call from a real agent
Three lines with the official x402 libraries An agent with a wallet pays automatically: the library sees the 402, signs the payment and asks again. No account, no API key, no card.
import { wrapFetchWithPayment } from "@x402/fetch" ;
import { x402Client } from "@x402/core/client" ;
import { ExactSvmScheme } from "@x402/svm/exact/client" ;
import { createKeyPairSignerFromBytes } from "@solana/kit" ;
// the agent's own wallet, holding a little $ABC or USDC (no SOL needed)
const signer = await createKeyPairSignerFromBytes(agentSecretKeyBytes);
const client = new x402Client().register("solana:*" , new ExactSvmScheme(signer));
const fetchWithPay = wrapFetchWithPayment(fetch, client);
const res = await fetchWithPay(
"https://gateway.advancebitcoin.org/api/agent/token-check?mint=3BWcLccJqqiy2k3QsfnmZpsrKTH1jjVCNTFkVQ8dcY6d"
);
console.log(await res.json()); // the token check, plus the payment's transaction Want your own API to charge like this? Set up agent payments .