parseUnits

Learn about the parseUnits utils method

Introduction

The parseUnits method is used to parse a string or number representing an amount of a currency and convert it into the equivalent amount of wei.

Usage

This method should be used when you want to parse a string or number representing an amount of a currency and convert it into the equivalent amount of wei. This can be useful when working with amounts of currencies in your code, as it allows you to convert the amount into wei, which is the smallest unit of that currency.

Here's a simple code example to demonstrate how to use this method:

const { Utils } = require("alchemy-sdk");

let currencyAmount = "1.0";
let decimalPlaces = 18;

let weiAmount = Utils.parseUnits(currencyAmount, decimalPlaces); 
console.log(weiAmount); // '1000000000000000000'
ReadMe