| 6 | const hre = require("hardhat"); |
| 7 | |
| 8 | async function main() { |
| 9 | // Hardhat always runs the compile task when running scripts with its command |
| 10 | // line interface. |
| 11 | // |
| 12 | // If this script is run directly using `node` you may want to call compile |
| 13 | // manually to make sure everything is compiled |
| 14 | // await hre.run('compile'); |
| 15 | |
| 16 | // We get the contract to deploy |
| 17 | const Greeter = await hre.ethers.getContractFactory("Greeter"); |
| 18 | const greeter = await Greeter.deploy("Hello, Hardhat!"); |
| 19 | |
| 20 | await greeter.deployed(); |
| 21 | |
| 22 | console.log("Greeter deployed to:", greeter.address); |
| 23 | } |
| 24 | |
| 25 | // We recommend this pattern to be able to use async/await everywhere |
| 26 | // and properly handle errors. |