stringToBytes

Converts a string to an array of bytes.

Example

import { stringToBytes } from "thirdweb/utils";
const bytes = stringToBytes("Hello, world!");
console.log(bytes); // Uint8Array(13) [ 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33 ]
function stringToBytes(
value: string,
): Uint8Array;

Parameters

The string to convert.

Type

let value: string;

Optional parameters for the conversion.

Type

let opts: { size?: number };

Returns

let returnType: Uint8Array;

The array of bytes representing the string.