deploy.ts 728 B

1234567891011121314151617181920212223
  1. import { ethers } from "hardhat";
  2. async function main() {
  3. const currentTimestampInSeconds = Math.round(Date.now() / 1000);
  4. const ONE_YEAR_IN_SECS = 365 * 24 * 60 * 60;
  5. const unlockTime = currentTimestampInSeconds + ONE_YEAR_IN_SECS;
  6. const lockedAmount = ethers.utils.parseEther("1");
  7. const Lock = await ethers.getContractFactory("Lock");
  8. const lock = await Lock.deploy(unlockTime, { value: lockedAmount });
  9. await lock.deployed();
  10. console.log(`Lock with 1 ETH and unlock timestamp ${unlockTime} deployed to ${lock.address}`);
  11. }
  12. // We recommend this pattern to be able to use async/await everywhere
  13. // and properly handle errors.
  14. main().catch((error) => {
  15. console.error(error);
  16. process.exitCode = 1;
  17. });