无法读取未定义的属性(读取“parseUnits”)- Hardhat js

问题描述 投票:0回答:2

尝试在测试函数中使用

ethers.utils.parseUnits("1", "ether")
时,会抛出错误
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")
})

我也尝试过使用 parseEther 得到相同的结果。在 ethers.utils.parseUnits 的文档规范中,它说只使用它。我还缺少其他功能吗?我的以太配置可能不正确吗?

javascript solidity chai ethers.js hardhat
2个回答
9
投票
ethers 版本 6 开始

ethers.utils.parseUnit() 已被

ethers.parseUnit()
 取代
    


0
投票

© www.soinside.com 2019 - 2024. All rights reserved.