Skip to content

Commit

Permalink
Merge pull request #3731 from NomicFoundation/improve-3662
Browse files Browse the repository at this point in the history
Improve on #3662 by sending less ETH and locking it for a shorter time
  • Loading branch information
fvictorio authored Mar 2, 2023
2 parents e51bb21 + 7a5bc55 commit 18b08c5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-cameras-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Send less ETH and lock it for less time on sample deployment scripts.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
import hre from "hardhat";

const currentTimestampInSeconds = Math.round(Date.now() / 1000);
const ONE_YEAR_IN_SECS = 365 * 24 * 60 * 60;
const unlockTime = currentTimestampInSeconds + ONE_YEAR_IN_SECS;
const unlockTime = currentTimestampInSeconds + 60;

const lockedAmount = hre.ethers.utils.parseEther("1");
const lockedAmount = hre.ethers.utils.parseEther("0.001");

const Lock = await hre.ethers.getContractFactory("Lock");
const lock = await Lock.deploy(unlockTime, { value: lockedAmount });

await lock.deployed();

console.log(
`Lock with 1 ETH and unlock timestamp ${unlockTime} deployed to ${lock.address}`
`Lock with ${ethers.utils.formatEther(
lockedAmount
)}ETH and unlock timestamp ${unlockTime} deployed to ${lock.address}`
);
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ const hre = require("hardhat");

async function main() {
const currentTimestampInSeconds = Math.round(Date.now() / 1000);
const ONE_YEAR_IN_SECS = 365 * 24 * 60 * 60;
const unlockTime = currentTimestampInSeconds + ONE_YEAR_IN_SECS;
const unlockTime = currentTimestampInSeconds + 60;

const lockedAmount = hre.ethers.utils.parseEther("0.01");
const lockedAmount = hre.ethers.utils.parseEther("0.001");

const Lock = await hre.ethers.getContractFactory("Lock");
const lock = await Lock.deploy(unlockTime, { value: lockedAmount });

await lock.deployed();

console.log(
`Lock with 0.01 ETH and unlock timestamp ${unlockTime} deployed to ${lock.address}`
`Lock with ${ethers.utils.formatEther(
lockedAmount
)}ETH and unlock timestamp ${unlockTime} deployed to ${lock.address}`
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import { ethers } from "hardhat";

async function main() {
const currentTimestampInSeconds = Math.round(Date.now() / 1000);
const ONE_YEAR_IN_SECS = 365 * 24 * 60 * 60;
const unlockTime = currentTimestampInSeconds + ONE_YEAR_IN_SECS;
const unlockTime = currentTimestampInSeconds + 60;

const lockedAmount = ethers.utils.parseEther("0.01");
const lockedAmount = ethers.utils.parseEther("0.001");

const Lock = await ethers.getContractFactory("Lock");
const lock = await Lock.deploy(unlockTime, { value: lockedAmount });

await lock.deployed();

console.log(`Lock with 0.01 ETH and unlock timestamp ${unlockTime} deployed to ${lock.address}`);
console.log(
`Lock with ${ethers.utils.formatEther(lockedAmount)}ETH and unlock timestamp ${unlockTime} deployed to ${lock.address}`
);
}

// We recommend this pattern to be able to use async/await everywhere
Expand Down

0 comments on commit 18b08c5

Please sign in to comment.