【问题标题】:Ethereum hardhat - NomicLabsHardhatPluginError: abstract contract factory for the contract ERC1155Facet can't be deployed以太坊安全帽 - NomicLabsHardhatPluginError:无法部署合约 ERC 1155 Facet 的抽象合约工厂
【发布时间】:2021-10-14 20:34:51
【问题描述】:

我正在尝试使用以太坊的 solidity 和 nomiclabs 安全帽中的抽象合约来部署智能合约。

但我的“test.ts”脚本中不断出现以下错误。

可能是什么问题?

提前致谢!

错误:


"before all" hook for "Check that all functions and facets exist in the diamond":
     
NomicLabsHardhatPluginError: You are trying to create a contract factory for the contract ERC1155Facet, which is abstract and can't be deployed.
If you want to call a contract using ERC1155Facet as its interface use the "getContractAt" function instead.
at getContractFactoryByName (node_modules\@nomiclabs\hardhat-ethers\src\internal\helpers.ts:112:11)
at deployFacets (test\test.js:74:25)
at Context.<anonymous> (test\test.js:90:9)

ERC 合约代码如下所示:

ERC1155MintBurnPB.sol:


abstract contract ERC1155MintBurnPB is ERC1155PB { }

ERC1155PB.sol:


abstract contract ERC1155PB is IERC1155 { }

ERC1155Facet.sol


abstract contract ERC1155Facet is ERC1155MintBurnPB { }

test.ts 长这样:

...
...
const factory = await ethers.getContractFactory(facet, signer);
...
...

【问题讨论】:

    标签: ethereum solidity hardhat


    【解决方案1】:

    抽象合约不可部署。它们可用于继承自定义常规合约的底层函数。

    从您要部署的合约中删除 abstract 关键字,然后重试!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-23
      • 2016-02-28
      • 2018-03-15
      • 1970-01-01
      • 1970-01-01
      • 2019-04-07
      • 2018-11-29
      相关资源
      最近更新 更多