// An example of a deploy script that will deploy and call a simple contract. exportdefaultasyncfunction (hre: HardhatRuntimeEnvironment) { console.log(`Running deploy script for the Greeter contract`);
// Initialize the wallet. const wallet = newWallet("<WALLET-PRIVATE-KEY>");
// Create deployer object and load the artifact of the contract you want to deploy. const deployer = newDeployer(hre, wallet); const artifact = await deployer.loadArtifact("Greeter");
// Deploy this contract. The returned object will be of a `Contract` type, similarly to ones in `ethers`. // `greeting` is an argument for contract constructor. const parsedFee = ethers.utils.formatEther(deploymentFee.toString()); console.log(`The deployment is estimated to cost ${parsedFee} ETH`);
//obtain the Constructor Arguments console.log("constructor args:" + greeterContract.interface.encodeDeploy([greeting]));
// Show the contract info. const contractAddress = greeterContract.address; console.log(`${artifact.contractName} was deployed to ${contractAddress}`); }
If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you !