deploy.ts 924 B

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