@nevermined-io/payments
    Preparing search index...

    Function normalizeCredits

    Machine Payments Protocol (MPP) module.

    • Normalizes credits to the exact decimal-string amount that gets sealed into the challenge and burned. A bare .toString() on a JS number can emit scientific notation (1e+21), "NaN" or "Infinity" — all forwarded unvalidated into an amount this PR's own docs describe as having "no post-hoc re-pricing as there is with x402": a corrupted amount here is not correctable downstream, it IS the amount.

      BigInt(x) renders an integer-valued number exactly (no scientific notation) and throws RangeError on a non-integer, NaN or Infinity instead of silently stringifying them — which is why non-string inputs go through it. The string arm gets its own check instead of relying on BigInt's string parsing, which is far more permissive than a decimal string contract should be.

      Parameters

      • credits: string | number | bigint

      Returns string