numberToBytes

Converts a number to bytes.

Example

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

Parameters

The number to convert.

Type

let value: number | bigint;

Options for converting the number to hex.

Type

let opts:
| { signed?: boolean; size: number }
| { signed?: never; size?: number };

Returns

let returnType: Uint8Array;

The bytes representation of the number.