Function bigIntToHex

  • Convert a bigint to a hexadecimal string. This verifies that the bigint is a non-negative integer.

    To convert a number to a hexadecimal string instead, use numberToHex.

    Example

    bigIntToHex(0n); // '0x0'
    bigIntToHex(1n); // '0x1'
    bigIntToHex(16n); // '0x10'

    Returns

    The hexadecimal string, with the "0x"-prefix.

    Throws

    If the bigint is not a non-negative integer.

    Parameters

    • value: bigint

      The bigint to convert to a hexadecimal string.

    Returns `0x${string}`