I am developing two smart contracts whose deployment order matters. First comes an ERC20 token, and then its deployment address should be passed to an ERC721 smart contract's constructor. Both contacts interaction was successfully tested on Hardhat. However, when following the Hardhat tutorial, I am trying to deploy these smart contracts to the RSK regtest local node with the following script:
const totalSuply = 1e6;
async function main() {
const ERC20 = await ethers.getContractFactory('ERC20');
const erc20 = await ERC20.deploy(totalSuply);
const ERC721 = await ethers.getContractFactory('ERC721');
const erc721 = await ERC721.deploy(erc20.address);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
I receive the following error:
Error:
transaction failed
[ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ](transactionHash="0xac83bdd94bf43eaec2e930497aa9a637883ad870749e5ee14cf8ba4ff332a810",
transaction {
"hash":"0xac83bdd94bf43eaec2e930497aa9a637883ad870749e5ee14cf8ba4ff332a810",
"type":0,
"accessList":null,
"blockHash":null,
"blockNumber":null,
"transactionIndex":null,
"confirmations":0,
"from":"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826",
"gasPrice":{"type":"BigNumber","hex":"0x00"},
"gasLimit":{"type":"BigNumber","hex":"0x1204a5"},
"to":null,"value":{"type":"BigNumber","hex":"0x00"},
"nonce":736,"data":...
According to the specified link, the most likely reason for that is:
This may happen if you failed to wait until the contract was deployed.
Since am already await
-ing for the deployments, how is this possible? Has anyone encountered similar problems deploying smart contracts on RSK via Hardhat?
For references, this is the hardhat.config.js
file I'm using:
require('@nomiclabs/hardhat-waffle');
module.exports = {
solidity: '0.8.1',
defaultNetwork: 'rskregtest',
networks: {
hardhat: {},
rskregtest: {
url: 'http://localhost:4444',
},
},
};