Skip to main content

toHex

Callable

  • toHex(value: string | number | bigint | boolean | object | Uint8Array, returnType?: boolean): string

  • Auto converts any given value into it's hex representation.

    @example
    console.log(web3.utils.toHex(10));
    > 0xa

    console.log(web3.utils.toHex('0x123', true));
    > bytes

    Parameters

    • value: string | number | bigint | boolean | object | Uint8Array

      Value to be converted to hex

    • optionalreturnType: boolean

      If true, it will return the type of the value

    Returns string