Skip to content

feat(x402): advertise upto scheme + send settlementOverrides#182

Merged
badjer merged 3 commits into
mainfrom
feat/x402-upto-phase3
Jun 18, 2026
Merged

feat(x402): advertise upto scheme + send settlementOverrides#182
badjer merged 3 commits into
mainfrom
feat/x402-upto-phase3

Conversation

@badjer

@badjer badjer commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

The SDK half of x402 up-to (metered) payments. Pairs with accounts (circuitandchisel/accounts#803) and the auth settle PR.

  • omniChallenge.buildX402Requirements advertises scheme=upto for EVM (Base) x402 options (SVM stays exact — Solana upto not implemented). The deployed SDK version thus selects exact vs upto; no runtime flag.
  • ProtocolSettlement.buildRequestBody adds settlementOverrides.amount (atomic micro-USDC from the metered actualAmount) for x402, so the facilitator settles the actual (≤ the Permit2 cap). settlePaymentSession passes session.spent as actualAmount.
  • x402Wrapper / baseAccount (self-custody client paths) select UptoEvmScheme vs ExactEvmScheme from the chosen accept's scheme.

Verified end-to-end on Base mainnet (see accounts#803): metered 3×$0.001 settled $0.003 on-chain. atxp-server 217 tests green.

🤖 Generated with Claude Code

badjer and others added 3 commits June 17, 2026 20:41
- omniChallenge buildX402Requirements advertises scheme=upto for EVM (Base) x402
  options (SVM stays exact; Solana upto not implemented). The deployed SDK version
  thus selects exact vs upto.
- ProtocolSettlement.buildRequestBody adds settlementOverrides.amount (atomic
  micro-USDC from the metered actualAmount) for x402, so settle charges the actual
  (<= the Permit2 cap). settlePaymentSession passes session.spent as actualAmount.
- x402Wrapper / baseAccount select UptoEvmScheme vs ExactEvmScheme from the chosen
  accept's scheme (self-custody client paths).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…te overrides

Review fixes for x402 up-to:
- buildX402Requirements advertises BOTH 'exact' and 'upto' per EVM chain (upto only
  when a facilitatorAddress is available), so non-accounts clients keep an exact
  fallback and accounts picks the scheme. upto accepts carry extra.facilitatorAddress,
  fetched once from auth's GET /x402/supported (cached). Dedupe accepts by
  (scheme, network) so a chain surfaced twice isn't advertised twice.
- buildRequestBody adds settlementOverrides ONLY for the upto scheme (exact/EIP-3009
  commits the signature to a fixed value; overriding it mismatches the signature and
  the facilitator rejects it). Clamp the override to the cap.
- Revert the self-custody paths (x402Wrapper, baseAccount) to exact-only — they
  can't complete upto (no facilitator approval); the accounts-mediated path is the
  only upto path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…n settle

Re-review:
- Bound the facilitator-address cache with a 10-minute TTL (was process-lifetime).
  The CDP settle address rotates; a long-lived process would advertise a stale
  witness and silently revert every upto settle until restart.
- buildRequestBody's full-accepts branch matched by network only; the challenge now
  carries both exact and upto per network, so match by scheme too (else a network
  match returns exact-first and drops the override). Added a same-network test.
- Dropped the stale "EVM payloads don't embed accepted" comment (createPaymentPayload
  does embed accepted for v2).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@badjer badjer merged commit 2064c6c into main Jun 18, 2026
1 check passed
@badjer badjer deleted the feat/x402-upto-phase3 branch June 18, 2026 18:14
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