toBytes

Converts a value to an array of bytes.

Example

import { toBytes } from "thirdweb/utils";
const bytes = toBytes("0x1a4");
console.log(bytes); // Uint8Array(2) [ 1, 164 ]
function toBytes(
value: string | number | bigint | boolean,
): Uint8Array;

Parameters

The value to convert.

Type

let value: string | number | bigint | boolean;

Optional parameters for the conversion.

Type

let opts: { size?: number };

Returns

let returnType: Uint8Array;

The array of bytes representing the value.