Function convertToRawAmount

  • Convert a SupportedNumber or RawAmount into RawAmount with optional specified decimals. The function throws error under these conditions:

    • When the input number is not a base-10 number.
    • When the specified decimals is not an integer number between 0 and 78 (inclusive).
    • When the decimals argument is incompatible with num.decimals.
    • When the calculated value is out of range.

    Parameters

    • num: bigint | SupportedNumber

      The input number to convert.

    • Optional decimals: number

      The optional number of decimals to use for the conversion.

    Returns RawAmount

    • The converted RawAmount.

    Throws

    Will throw an error if the input number is not a base-10 number or the specified decimals is invalid.