未找到以太功能

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

我刚刚浏览了安全帽的文档,很早就遇到了一个问题。

当我尝试使用以下安全帽功能进行部署时:

async function deployTokenFixture() {
    const hardhatToken = await ethers.deployContract("Token");

    await hardhatToken.waitForDeployment();
}

我收到此错误:

hardhatToken.waitForDeployment is not a function

我相当确定我的 Ethers 库有问题,但我不知道如何修复它。

我尝试重新安装正在运行的以太库

npm install @nomiclabs/ethers

还有

npm install @nomiclabs/hardhat-deploy-ethers

两者都没有解决我的问题

node.js mocha.js solidity hardhat
1个回答
0
投票

你可以试试这个,看看是否有效:

  // Deploy the contract
  const Token = await ethers.getContractFactory("Token");
  const hardhatToken = await Token.deploy();

  // Wait for the deployment to complete
  await hardhatToken.deployed();

  // Now the contract is deployed and ready to use
}
© www.soinside.com 2019 - 2024. All rights reserved.