formatUnits

Learn about the formatUnits utils method

Introduction

The formatUnits method is used to convert a value in wei to a more human-readable representation. This method is particularly useful for working with EVM values as the wei denomination is often not easily readable for users.

Usage

This method should be used when converting values from wei to more human-readable denominations. For example, converting from wei to ether.

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

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

let weiValue = "1000000000000000000";
let formattedWei = Utils.formatUnits(weiValue, "ether"); 
console.log(formattedWei); // '1.0 ETH'
ReadMe