PQ-402
PQ-402 is x402 made post-quantum. Like x402, it lets you charge for an HTTP API per request, with no
accounts or API keys: the server answers 402, the client pays, the server answers. PQ-402 keeps that flow and the x402
v2 wire format, and replaces the two parts a quantum computer breaks. The payment is an ML-DSA-87 signature checked on
the QoreChain testnet instead of an ECDSA one, and the request and the answer are sealed with ML-KEM-1024, so only the
payer can read the answer. It is for developers who sell an API and for developers whose code pays for one.
pnpm add @pq402/client @pq402/scheme-qorechainnpm install @pq402/client @pq402/scheme-qorechainyarn add @pq402/client @pq402/scheme-qorechainPay for a call from a script. The server’s 402 Payment Required is answered for you:
import { createPq402Fetch } from "@pq402/client";import { EvmChainReader, qorechainTestnet } from "@pq402/scheme-qorechain";import { deriveSealKeys } from "@qorechain/qoreseal";import { deriveUnifiedAccount } from "@qorechain/sdk";
const mnemonic = process.env.PAYER_MNEMONIC ?? "";const account = await deriveUnifiedAccount(mnemonic, 0);const pay = createPq402Fetch({ payer: account.evm as `0x${string}`, mldsaSecretKey: account.pqc.secretKey, // signs the payment (ML-DSA-87) sealKeys: deriveSealKeys({ mnemonic }), // opens the sealed answer (ML-KEM-1024) keys: new EvmChainReader({ network: qorechainTestnet }), chainId: qorechainTestnet.chainId, maxAmount: 10_000n, // at most 0.01 fUSD per call});const res = await pay("https://api.example.com/v1/answer", { method: "POST", body: "What is 6 x 7?" });console.log(await res.text(), res.payment?.settlement.transaction);QuickstartA paid, sealed call on your machine in under five minutes. No chain, no funds.
x402 and PQ-402What x402 does, its two weak points, and what PQ-402 replaces.
API referenceEvery export of the four @pq402 packages, generated from the source.