Search code examples
ethereumsolidityhardhat

Ethereum hardhat - NomicLabsHardhatPluginError: abstract contract factory for the contract ERC1155Facet can't be deployed


I'm trying to deploy smart contracts using abstract contracts in Ethereum's solidity and nomiclabs hardhat.

But I keep getting the following error in my 'test.ts' script.

What could be the problem?

Thanks in advance!

ERROR:


"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)

The ERC contract codes look like this:

ERC1155MintBurnPB.sol:


abstract contract ERC1155MintBurnPB is ERC1155PB { }

ERC1155PB.sol:


abstract contract ERC1155PB is IERC1155 { }

ERC1155Facet.sol


abstract contract ERC1155Facet is ERC1155MintBurnPB { }

test.ts long like this:

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

Solution

  • Abstract contracts are not deployable. They can be used to inherit the underlying functions on a custom, regular contract.

    Remove the abstract keyword from the contracts you want to deploy and try again!