Skip to content

fix: use dynamic decimals in getDisplayAmount instead of hardcoded USDC 6#1926

Open
natsukingly wants to merge 1 commit intox402-foundation:mainfrom
natsukingly:fix/display-amount-decimals
Open

fix: use dynamic decimals in getDisplayAmount instead of hardcoded USDC 6#1926
natsukingly wants to merge 1 commit intox402-foundation:mainfrom
natsukingly:fix/display-amount-decimals

Conversation

@natsukingly
Copy link
Copy Markdown

Summary

getDisplayAmount in x402HTTPResourceServer hardcodes / 1000000 assuming all assets use 6 decimals (USDC). This breaks display amounts for tokens like WBTC (8 decimals) or DAI (18 decimals).

Changes

  • Added getAssetDecimalsForRequirements method to x402ResourceServer that delegates to the registered scheme server's getAssetDecimals
  • Updated getDisplayAmount to dynamically determine decimals from the asset's scheme server
  • Falls back to 6 decimals when the scheme doesn't implement getAssetDecimals

Test plan

  • Full monorepo build passes
  • Verify display amounts render correctly for USDC (6), WBTC (8), and DAI (18)

@github-actions github-actions bot added typescript sdk Changes to core v2 packages labels Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sdk Changes to core v2 packages typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant