Wire format
Everything not listed here is x402 v2 as specified upstream. The full specification is
docs/spec.md in the repository.
Headers
Section titled “Headers”| Header | Direction | Content |
|---|---|---|
PAYMENT-REQUIRED |
server to client | x402 v2: base64 JSON with the price and the schemes offered |
PAYMENT-SIGNATURE |
client to server | x402 v2: the signed payment; 9,396 bytes measured |
PAYMENT-RESPONSE |
server to client | x402 v2: the settlement and the signed receipt; 9,052 bytes measured |
PQ402-Content-Type |
both | the original media type of a sealed body |
PQ402-Probe |
client to server | 1 on a sealing client’s first, body-less attempt |
A server should accept request headers of at least 16 KB. An ML-DSA-87 signature is 4,627 bytes, which base64 makes about 6.2 KB.
The 402
Section titled “The 402”Each scheme the server offers is one entry of accepts, with a scheme-specific extra:
| Scheme | extra |
|---|---|
pq-erc20 |
{ "escrow": "0x…", "version": "1" } |
pq-perennial |
{ "vault": "0x…", "version": "1" } |
With sealing on, extensions["pq402-sealing"].info says how:
{ "version": "1", "chainId": "qorechain-diana", "gateway": "0x…", "mode": "mlkem", "request": "required", "response": "sealed"}The client echoes info unchanged in its payment.
The payment
Section titled “The payment”pq-erc20:
{ "payer": "0x…", "nonce": "0x<64 hex>", "validAfter": "1763200000", "validBefore": "1763200120", "requestHash": "0x<64 hex>", "signature": "<base64 of 4627 bytes>"}pq-perennial:
{ "payer": "0x…", "positionId": "7", "nonce": "3", "deadline": "1763200120", "ref": "0x<64 hex>", "signature": "<base64 of 4627 bytes>"}Numbers are decimal strings. In pq-perennial, payer is the position’s beneficiary, nonce is the position’s
action nonce, and ref is the request hash.
Signed bytes
Section titled “Signed bytes”Every signed message is ABI-encoded and starts with a domain tag, so a signature for one kind of message, chain or contract is useless for another:
| Message | Domain tag |
|---|---|
payment (pq-erc20) |
keccak256("PQ-402/v1 payment") |
| request hash | keccak256("PQ-402/v1 request") |
| escrow withdrawal | keccak256("PQ-402/v1 withdrawal") |
| receipt | keccak256("PQ-402/v1 receipt") |
spend (pq-perennial) |
the vault’s own ACTION_DOMAIN, keccak256("Perennial.Action") |
The request hash covers the method, the path with its query, and the body bytes as sent (the sealed envelope when
sealed). The bytes are pinned by known-answer vectors that the TypeScript and Solidity tests both check:
v1.json.
Sealed bodies
Section titled “Sealed bodies”A sealed body is a QoreSeal envelope in ML-KEM-1024 mode, sent with Content-Type: application/vnd.pq402.sealed.
| QoreSeal purpose | Bound to (aad) |
|
|---|---|---|
| request | pq402-request |
METHOD + " " + path + "\n" + content type |
| response | pq402-response |
request hash, then content type |