Agents and x402
An agent that holds
USDC in a Solana wallet can buy questions on its own, with no site, no browser wallet and no account. It pays with x402, the open standard for paying inside an HTTP request, and then asks questions the same way the connector does: each request carries a fresh key that proves it was paid for without saying which membership paid.
The quickest way: the connector
The connector can buy for you. Point PARANOID_PAYER at a Solana keypair file (the JSON the
Solana CLI writes) whose wallet holds the
USDC.
curl -O https://paranoid.red/connect.mjs
PARANOID_PAYER=agent-wallet.json node connect.mjs buy 500
It makes a new secret on your computer, saves it in ~/.paranoid/connector.json (readable only by you), pays for 500 questions, and starts serving the OpenAI API on
http://127.0.0.1:4141/v1. Later runs need only node connect.mjs. When the questions run out, run buy again; the old membership's file is kept next to the new one.
The wallet needs
USDC only. The gateway pays the network fees.
Any x402 client
The endpoint is a plain x402 resource, so any client that pays with the exact scheme on Solana can use it, such as Coinbase's
@x402/fetch with @x402/svm.
POST https://paranoid.red/api/x402/join?questions=<n>&commitment=<hex>
- Make a secret: a random number below the BN254 field size. Keep it. Whoever has it can spend the questions.
- The commitment is
Poseidon(secret), written in hex. Only the commitment is sent. - Call the endpoint. The first answer is
402 Payment Requiredwith the price in thePAYMENT-REQUIREDheader (x402 version 2) and in the body (version 1). Your client pays and sends the request again withPAYMENT-SIGNATURE(orX-PAYMENT). - On success the answer is
200with the membership's address and the payment and deposit transactions.
To ask questions from that membership with the connector, run node connect.mjs and paste <secret>.0 as the code.
The price
The price is the questions at the usual rate (0.002
USDC each, 250 at least) plus a setup fee of 0.30
USDC. The fee covers what the gateway pays to open the membership: the rent for its account on Solana and two network fees. The 402 answer always carries the exact amount.
What the chain shows
The payment shows that your wallet paid the gateway, with a memo that is a hash of the commitment and the number of questions. The membership is then bought by the gateway, so the gateway's wallet is its depositor, not yours. The questions themselves are proven in zero knowledge, so a question names no membership and no two questions can be tied together. If the wallet itself must stay unknown, pay from a wallet that has no history.
Errors
A payment that does not match the request is refused before the gateway signs anything, so it costs nothing. The reason is in the PAYMENT-RESPONSE header.
| Reason | Meaning |
|---|---|
invalid_amount | The transfer is less than the price. |
invalid_recipient | The transfer goes somewhere other than the gateway's |
invalid_memo | The memo is missing or belongs to another commitment or another number of questions. |
fee_payer_in_instruction | The transaction asks the gateway's fee payer to do more than pay the fee. |
simulation_failed | The transaction would fail, usually for lack of |
Sending the same paid request again returns the same answer and buys nothing more. A payment never buys for a commitment other than the one it was made for.