Skip to content

docs(x402): fix gasless upto setup and v2 header names (verified e2e)#14

Merged
nolnol3 merged 3 commits into
mainfrom
docs/x402-e2e-fixes
Jun 30, 2026
Merged

docs(x402): fix gasless upto setup and v2 header names (verified e2e)#14
nolnol3 merged 3 commits into
mainfrom
docs/x402-e2e-fixes

Conversation

@nolnol3

@nolnol3 nolnol3 commented Jun 30, 2026

Copy link
Copy Markdown
Member

Follow-up to #13. These fixes were found by running the documented Quickstart: Sellers and Quickstart: Buyers code verbatim against the public HPP Sepolia facilitator (a 0-ETH buyer paying gasless upto).

Bug 1 — Seller quickstart omitted the gasless extension

The upto route did not declare declareEip2612GasSponsoringExtension(). Without it the facilitator can't sponsor the buyer's Permit2 approval, so a 0-ETH buyer is rejected with permit2_allowance_required once its standing allowance is exhausted (reproduced: allowance 9951 < 10000 → 412; after adding the extension → settles).

  • Add the extension + explanation to "Accepting upto and gasless payments"
  • Add @x402/extensions to install line and the SDK package table
  • Add a :::note on the Facilitator page

Bug 2 — v1 header names

The docs used the x402 v1 header spelling. This (v2) SDK uses:

  • request: payment-signature (docs said X-PAYMENT)
  • receipt: payment-response (docs said X-PAYMENT-RESPONSE)
  • 402: payment-required

The buyer's receipt code read x-payment-response, so it never fired. Fixed the buyer code, the how-it-works diagram/text, and prose across pages. Also softened the receipt.amount note (it is optional in SettleResponse).

Verification

After the fixes, the documented buyer code returns 200 and prints the receipt:
SETTLED tx: 0xb8cdc6f3…34f4 network: eip155:181228, with the buyer's USDC.e balance decreasing on-chain — all gasless (buyer holds 0 ETH).

npm run build passes with `onBrokenLinks: 'throw'`.

Found via real end-to-end runs against the public Sepolia facilitator
(0-ETH buyer paying gasless `upto`):

- Seller quickstart omitted `declareEip2612GasSponsoringExtension()` on the
  `upto` route. Without it the facilitator can't sponsor the buyer's Permit2
  approval, so a 0-ETH buyer is rejected with `permit2_allowance_required`
  once its standing allowance is exhausted. Add the extension + explanation,
  and add `@x402/extensions` to install/package list.
- Header names were the x402 v1 spelling. This (v2) SDK uses `payment-response`
  (receipt), `payment-signature` (request), `payment-required` (402). Fix the
  buyer receipt code, the how-it-works diagram/text, and prose across pages.
- Soften the `receipt.amount` note (it is optional in SettleResponse).
@nolnol3 nolnol3 requested a review from hayarobi June 30, 2026 01:57
nolnol3 added 2 commits June 30, 2026 11:03
Verified e2e against the public Sepolia facilitator with a 0-ETH buyer:
both `exact` and `upto` settle on-chain while the buyer's ETH stays 0 — the
facilitator submits settlement and pays the gas.

The previous wording claimed `exact` needs buyer ETH and only `upto` could be
gasless; that is backwards. Correct the Buyers prerequisites/intro and the
Networks & Token funding section: the buyer needs no ETH for `exact`, and none
for `upto` when the seller enables EIP-2612 sponsoring (only a non-sponsored
upto's one-time Permit2 approval costs the buyer a little ETH).
…ippet

- how-it-works: state that the facilitator relays settlement and pays gas for
  `exact` (buyer needs no ETH), and that `upto`'s only extra cost is the
  one-time Permit2 approval, sponsored when the seller enables it. Keeps the
  scheme overview consistent with the Buyers/Networks guidance.
- sellers: note the "Accepting upto" snippet replaces the step-4 route and
  reuses the same `price` / `PAY_TO`.
@nolnol3 nolnol3 merged commit d36af9d into main Jun 30, 2026
1 check passed
@nolnol3 nolnol3 deleted the docs/x402-e2e-fixes branch June 30, 2026 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant