How to pass constructor argument with hardhat? Is it something like this:
npx hardhat run scripts/deploy.js --network rinkeby --constructor args?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityYou've to add constructor arguments inside your deployment script.,
For eg.,
const hre = require("hardhat");
const ethers = hre.ethers;
async function main() {
const Greeter = await ethers.getContractFactory("Greeter");
const greeter = await Greeter.deploy("Hello World")
await greeter.deployed();
console.log("Contract deployed to:", greeter.address);
}
main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
For verification on etherscan using cli,
npx hardhat run scripts/deploy.js --network rinkeby --constructor-args arguments/greeter.arguments.js
where inside a folder called arguments, a file named greeter.arguments.js we will have the arguments to our deployed contract.
The arguments are given inside the script. The line you showed only executes the script and does little else - all the actual deployment logic is inside the script itself.