parseEther

Learn about the parseEther utils method

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:

Javascript
1const { Utils } = require("alchemy-sdk");
2
3let etherAmount = "1.0";
4
5let weiAmount = Utils.parseEther(etherAmount);
6console.log(weiAmount); // '1000000000000000000'