ether

ethers.utils.formatEther(10000000000, "ether") not working using ether.js


**CODE : ** const balanceEther = await ethers.utils.formatEther(10000000000, "ether");

ISSUE I write this line of code nd it shows the error written below ..

ERROR : TypeError: Cannot read properties of undefined (reading 'formatEther')

According to me it should have to convert the value of Wei to Ether but its showing the error...


Solution

  • you can use formatUnits function for convert

    const {ethers,formatUnits} =require('ethers');
    console.log(formatUnits(1000000000000,"ether"));
    

    this can help you for conversion