Learn about the toUtf8Bytes
utils method.
Introduction
The toUtf8Bytes
method is used to convert a string to its equivalent UTF-8 encoded byte array representation.
Usage
This method should be used when you want to convert a string to its UTF-8 encoded byte array representation. For example, you can use this method to convert the string 'Hello World'
to its UTF-8 encoded byte array representation.
Here's a simple code example to demonstrate how to use this method:
const { Utils } = require("alchemy-sdk");
let message = "Hello World";
let utf8Bytes = Utils.toUtf8Bytes(message);
console.log(utf8Bytes); // [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]