This is my constructor
constructor (uint256 _initialSupply) {
ownerOfContract = msg.sender;
balanceOf[msg.sender] = _initialSupply;
totalSupply = _initialSupply;
}
But when I deploy the contract, it gives me the following error:
{
reason: 'missing argument: in Contract constructor',
code: 'MISSING_ARGUMENT',
count: 0,
expectedCount: 1
}
Upon googling I came to know that constructor and deploy function should have same number of arguments when deploying through hardhat. But what should I pass in deploy()?
Best Answer
When you call
Contract.deploy()
, you just need to pass the constructor parameters in the order they are declared in your contract, like this:Contract.deploy(initialSupply)
, orContract.deploy("100000000")
;If your constructor looked like this:
constructor (uint256 _initialSupply, string tokenName)
Then you would deploy it in hardhat like:
Contract.deploy("100000000", "TokenA")