deploy.ts 1.1 KB

1234567891011121314151617181920212223242526272829
  1. // We require the Buidler Runtime Environment explicitly here. This is optional
  2. // but useful for running the script in a standalone fashion through `node <script>`.
  3. // When running the script with `buidler run <script>` you'll find the Buidler
  4. // Runtime Environment's members available in the global scope.
  5. import { ethers } from "@nomiclabs/buidler";
  6. import { Contract, ContractFactory } from "ethers";
  7. async function main(): Promise<void> {
  8. // Buidler always runs the compile task when running scripts through it.
  9. // If this runs in a standalone fashion you may want to call compile manually
  10. // to make sure everything is compiled
  11. // await run("compile");
  12. // We get the contract to deploy
  13. const Greeter: ContractFactory = await ethers.getContractFactory("Greeter");
  14. const greeter: Contract = await Greeter.deploy("Hello, Buidler!");
  15. await greeter.deployed();
  16. console.log("Greeter deployed to: ", greeter.address);
  17. }
  18. // We recommend this pattern to be able to use async/await everywhere
  19. // and properly handle errors.
  20. main()
  21. .then(() => process.exit(0))
  22. .catch((error: Error) => {
  23. console.error(error);
  24. process.exit(1);
  25. });