0

我正在尝试使用以太坊的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);
...
...
4

1 回答 1

1

抽象合约不可部署。它们可用于继承自定义常规合约的基础功能。

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

于 2021-12-02T19:31:50.147 回答