Skip to content

fix(x402): meter the sender's STX fee on auto-payments - #714

Merged
biwasxyz merged 1 commit into
mainfrom
fix/x402-meter-fee
Oct 8, 2026
Merged

biwasxyz merged 1 commit into
mainfrom
fix/x402-meter-fee

Conversation

@biwasxyz

@biwasxyz biwasxyz commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

createApiClient booked only the payment amount. The self-paid transaction's fee (sbtc_transfer / token_transfer clamp, up to 0.003 STX) was never metered, so x402 gas was uncapped, unlike transferStx and callContract.

  • Resolve the fee once, before reserve(), and book it in ustx alongside the amount (one multi-unit reservation, booked whole or not at all).
  • Both signers reuse that fee, so the booked fee is the one in the transaction.
  • Test covers sBTC (sats + ustx fee) and STX (ustx amount + ustx fee); it fails without the fix.

Closes #713

createApiClient booked only the payment amount; the self-paid fee (up to
0.003 STX) was never metered, so x402 gas was uncapped unlike transferStx
and callContract. The fee is now resolved before reserve() and booked in
ustx with the amount.

Closes #713
@biwasxyz
biwasxyz merged commit ce6dd7c into main Oct 8, 2026
5 checks passed
@biwasxyz
biwasxyz deleted the fix/x402-meter-fee branch October 8, 2026 14:38
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.

spend limit: x402 auto-payments do not meter the sender's STX fee

1 participant