hexToUint8Array

Converts a hexadecimal string to a Uint8Array.

Example

import { hexToUint8Array } from "thirdweb/utils";
const bytes = hexToUint8Array("0x48656c6c6f2c20776f726c6421");
console.log(bytes); // Uint8Array([72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33])
function hexToUint8Array(
hex: `0x${string}`,
opts: Options,
): Uint8Array;

Parameters

The hexadecimal string to convert.

Type

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

Options for the conversion.

Type

let opts: Options;

Returns

let returnType: Uint8Array;

The Uint8Array representation of the hexadecimal string.