Skip to content

bug(paywall): EVM paywall hardcodes 6 decimals — breaks non-6-decimal tokens #1979

@ryanRfox

Description

@ryanRfox

Bug

The EVM paywall assumes all payment tokens use 6 decimal places (like USDC). Tokens with different precision render incorrect amounts.

Where:

  • typescript/packages/http/paywall/src/evm/index.ts line 37: parseFloat(requirement.amount) / 1000000 — hardcoded 10^6 divisor
  • typescript/packages/http/paywall/src/evm/EvmPaywall.tsx line 78: formatUnits(balance, 6) — hardcoded 6 for balance display
  • typescript/packages/http/paywall/src/evm/utils.ts: getUSDCBalance() uses hardcoded USDC addresses for 3 chains only

Impact: Any token with non-6 decimals displays incorrectly. For example, an 18-decimal token priced at 0.001 (raw: 10^15) shows as $1,000,000,000 in the paywall UI. This already affects MegaETH/MegaUSD (18 decimals, in DEFAULT_STABLECOINS since v2.7.0).

Who it affects: Any chain in DEFAULT_STABLECOINS with decimals != 6. Currently: MegaETH (eip155:4326, MegaUSD, 18 decimals). Any new chain adding a non-6-decimal default token.

Expected behavior: The paywall should use the correct decimal precision for the payment token rather than assuming 6. The server-side amount conversion can read decimals from the default asset registry (getDefaultAsset). The client-side balance display can query the standard ERC-20 decimals() function, which every compliant token implements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions