Function hexToBigInt

  • Convert a hexadecimal string to a bigint. This verifies that the string is a valid hex string. Both "0x"-prefixed and unprefixed strings are supported.

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

    Example

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

    Returns

    The bigint.

    Throws

    If the value is not a valid hexadecimal string.

    Parameters

    • value: string

      The hexadecimal string to convert to a bigint.

    Returns bigint