javascriptsoliditychaiethers.jshardhat

Cannot read properties of undefined (reading 'parseUnits') - Hardhat js


When trying to use ethers.utils.parseUnits("1", "ether") in a test function an error is thrown TypeError: Cannot read properties of undefined (reading 'parseUnits').

const { deployments, ethers, getNamedAccounts } = require("hardhat")
const { assert, expect } = require("chai")
describe("FundMe", async function () {
    let fundMe
    let deployer
    const sendValue = ethers.utils.parseUnits("1", "ether")
})

I have tried using parseEther as well with the same result. In the documentation specification for ethers.utils.parseUnits it says to use just that. Is there another function that I am missing? Could my ethers config be incorrect?


Solution

  • As of ethers version 6 ethers.utils.parseUnit() has been replaced by ethers.parseUnit()