fromHex

Converts a hexadecimal string to the specified type.

Example

import { fromHex } from "thirdweb/utils";
const string = fromHex("0x48656c6c6f2c20776f726c6421", "string");
console.log(string); // "Hello, world!"
function fromHex(
hex: `0x${string}`,
toOrOpts: FromHexParameters<TTo>,

Parameters

The hexadecimal string to convert.

Type

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

The target type or conversion options.

Type

let toOrOpts: FromHexParameters<TTo>;

Returns

let returnType: FromHexReturnType<TTo>;

The converted value of the specified type.