deploy.ts 895 B

12345678910111213141516171819202122
  1. // We require the Hardhat Runtime Environment explicitly here. This is optional but useful for running the
  2. // script in a standalone fashion through `node <script>`. When running the script with `hardhat run <script>`,
  3. // you'll find the Hardhat Runtime Environment's members available in the global scope.
  4. import { ethers } from "hardhat";
  5. import { Greeter, Greeter__factory } from "../typechain";
  6. async function main(): Promise<void> {
  7. const Greeter: Greeter__factory = await ethers.getContractFactory("Greeter");
  8. const greeter: Greeter = await Greeter.deploy("Hello, Hardhat!");
  9. await greeter.deployed();
  10. console.log("Greeter deployed to: ", greeter.address);
  11. }
  12. // We recommend this pattern to be able to use async/await everywhere and properly handle errors.
  13. main()
  14. .then(() => process.exit(0))
  15. .catch((error: Error) => {
  16. console.error(error);
  17. process.exit(1);
  18. });