toHex

Converts a value to its hexadecimal representation.

Example

import { toHex } from "thirdweb/utils";
const hex = toHex(420);
console.log(hex); // "0x1a4"
function toHex(
value: string | number | bigint | boolean | Uint8Array,
): Hex;

Parameters

The value to convert to hexadecimal.

Type

let value: string | number | bigint | boolean | Uint8Array;

Optional parameters for the conversion.

Type

let opts: { size?: number };

Returns

let returnType: `0x${string}`;

The hexadecimal representation of the value.