Repository navigation
feat(sdk): initX402({ maxAmountPerPayment }) to raise the x402 per-payment cap - #130
Merged
Eras256 merged 1 commit intoOct 13, 2026
Merged
Conversation
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.
Closes #106
What
initX402()now accepts an optionalmaxAmountPerPayment, passed to @x402/core asspendControls.maxAmountPerPayment, so APIs priced above $1 can be paid with Nirium.Checked against @x402/core 2.28.0 (installed, not older docs)
x402Client.setSpendControls(controls);SpendControls.maxAmountPerPayment?: Money | false, defaultDEFAULT_MAX_AMOUNT_PER_PAYMENT = "$1".applySpendControls, before the payload is created, so a blocked payment never reaches the signer.Design
'$5','5'or5, normalized to"$N". Validated atinitX402()time: positive amounts only.0, negatives,NaN,Infinity, exponent/comma forms,nullandfalsethrow. Disabling the cap (false) is intentionally not exposed; raising it must be an explicit, bounded choice.setSpendControlsis not called, so the $1 default and current behavior are unchanged.x402Fetchand thepolicypath. With a policy, a payment above the cap is refused before the policy or the signer is consulted.X402SpendCapErrormessage now points to the option instead of saying it cannot be changed.Tests (
test/x402-spend-cap-config.test.ts, e2e on dist/ with the in-memory x402-edges fixtures)$1, signer never called, no paid retry'$2','2',2,'1.01'): $1.01 pays, signed exactly oncepolicy+ raised cap: pays under the cap; above it the policy is not asked and the signer is not calledFull suite on Node 22.12.0: jest 56/56, node:test 126/126.
Docs
README "Per-payment cap" documents the option and why the $1 default exists. CHANGELOG "Unreleased" entry.
AI disclosure
This PR was written with AI assistance under my direction: the AI read @x402/core 2.28.0, drafted the change, tests and docs. I reviewed the diff and the test results by hand before opening it.