Your 402 header cannot be trimmed: the client echoes the offer you handed it
A 402 challenge has a hard size ceiling and no clean way out of it. The header is a single line, some HTTP servers refuse over 8,190 bytes, and the obvious fix — "send a smaller version of the offer" — does not work. Not because it is a bad idea, but because of one line in the reference client.
// @x402/core 2.28.0, dist/cjs/client/index.js:457 accepted: requirements The client does not rebuild the offer it was handed. It echoes it, whole, into the PAYMENT-SIGNATURE your server receives. Trim one field from the header offer and the retry carries the trimmed copy — which means any server-side check that compares the payment against its own requirement sees a different object.
I measured this rather than reasoned about it, because the two answers diverge in a way that matters.
The predicate, and why it is not empty
The rule people reach for is: a subfield is safe to drop iff removing it leaves every conforming client's PAYMENT-SIGNATURE byte-identical. That rule is correct. Run it against 2.28.0 and almost nothing passes.
Start with what the signature actually covers. For exact-eip3009 the EIP-712 message has six fields:
{ from, to, value, validAfter, validBefore, nonce } extra is not in it. extra.name and extra.version build the domain, not the message. Two payloads signed from the same offer differ only in the freshly drawn nonce. So the signature bytes do not change when you trim extra.decimals or a free-text instructions field.
The header bytes do. Base64 of the payload, full offer vs trimmed:
full 1,144 B trimmed 1,092 B (52 B saved on decimals + free text) The 52 bytes are not a coincidence and not a rounding: the difference is exactly the echo of the two removed keys inside accepted. That is the distinction that decides the question — the signature is unchanged, the envelope is not, and the envelope is the line that has to fit.
It gets worse in two directions
Altering a core field fails the same way. paymentRequirementsMatchAccepted deep-equals the core fields before it looks at extra at all (dist/cjs/server/index.js:2344-2348). Dropping description from the header offer fails the match exactly as dropping decimals does — and it fails silently, findMatchingRequirements just returns undefined, which surfaces as a generic "no matching requirement" with no hint that the offer was mutated.
Removing name is not a mismatch, it is a thrown exception. The client will not build a payload at all:
Error: EIP-712 domain parameters (name, version) are required in payment requirements for asset 0x8335… That one is arguably good news — it fails at the caller, loudly — but it also means "compact the offer" has a failure mode that no server-side check can turn into a clean refusal. A seller who ships it will see payment builds fail in other people's code, not rejections in their own logs.
What is actually safe
Two dials, both structural:
- Drop whole offers, from the tail, never the first. Matching is against the server's advertised requirement set, so a surviving offer that is byte-identical still matches. The dropped ones simply become unpayable through this challenge — which is the point of a header that cannot hold them.
- Drop non-payment extension data, and do it first.
extensions.bazaaris not part of any offer, and because the client echoes extensions into the retry too, removing it shrinks both lines at once. One measured deployment went from 14–17 offers in the header to 16–19 out of 19–20 by dropping bazaar before anything else.
Everything else is off the table with today's client. Not because the fields are signed, but because the offer is echoed.
The sentence to put in a spec
Something like:
A server MAY omit offers, or non-payment extension data, from the challenge header. It MUST NOT alter any offer it includes — including by removing a field the payment scheme requires to construct a payload.
The second clause needs both halves. "Alter" covers the deep-equality failure on core fields; "including by removing" covers the thrown-exception case, which is a different failure class and deserves to be named.
One footnote for anyone writing the check: the subset comparison omits dynamicExtraFields before comparing (server/index.js:2349-2355), so a scheme that declares dynamic fields would make trimming legal. Nothing shipped in 2.28.0 declares any — ExactEvmScheme.dynamicExtraFields is undefined — so today the strict reading is the only reading. That could change without core moving, which is exactly the kind of thing a spec sentence should be robust to.
Why this is worth writing down
Our gateway builds the header from the same document as the body, one json.Marshal reached twice, so it never had this class of bug to fix. But the ceiling is real at ~8 KB per challenge, and the first seller who tries to get under it by compacting the offer will find that the failure is invisible from their side: the signature is valid, the payload is well-formed, and the only symptom is a match that returns nothing.
The measurements above are from a local run against the published package, not from a deployed edge — a reproduction script is about forty lines and worth having if you operate a seller.