Learn about the parseEther
utils method
Introduction
The parseEther
method is used to parse a string or number representing an amount of ether and convert it into a number of wei.
Usage
This method should be used when you want to parse a string or number representing an amount of ether and convert it into a number of wei. This can be useful when working with Ether amounts in your code, as it allows you to convert the amount into wei, which is the smallest unit of Ether.
Here's a simple code example to demonstrate how to use this method:
const { Utils } = require("alchemy-sdk");
let etherAmount = "1.0";
let weiAmount = Utils.parseEther(etherAmount);
console.log(weiAmount); // '1000000000000000000'