feat(x402): advertise upto scheme + send settlementOverrides#182
Merged
Conversation
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The SDK half of x402 up-to (metered) payments. Pairs with accounts (circuitandchisel/accounts#803) and the auth settle PR.
omniChallenge.buildX402Requirementsadvertisesscheme=uptofor EVM (Base) x402 options (SVM staysexact— Solana upto not implemented). The deployed SDK version thus selects exact vs upto; no runtime flag.ProtocolSettlement.buildRequestBodyaddssettlementOverrides.amount(atomic micro-USDC from the meteredactualAmount) for x402, so the facilitator settles the actual (≤ the Permit2 cap).settlePaymentSessionpassessession.spentasactualAmount.x402Wrapper/baseAccount(self-custody client paths) selectUptoEvmSchemevsExactEvmSchemefrom 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