enable compiler optimizer to spend less gas top deploy
This commit is contained in:
parent
3c14e5bf1c
commit
1569a17daa
|
@ -3,7 +3,15 @@ import "@nomicfoundation/hardhat-toolbox";
|
||||||
import "@openzeppelin/test-helpers";
|
import "@openzeppelin/test-helpers";
|
||||||
|
|
||||||
const config: HardhatUserConfig = {
|
const config: HardhatUserConfig = {
|
||||||
solidity: "0.8.17",
|
solidity: {
|
||||||
|
version: "0.8.17",
|
||||||
|
settings: {
|
||||||
|
optimizer: {
|
||||||
|
enabled: true,
|
||||||
|
runs: 200,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
import { ethers } from "hardhat";
|
import { ethers } from "hardhat";
|
||||||
|
import { pn } from "./utils";
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const currentTimestampInSeconds = Math.round(Date.now() / 1000);
|
const CollectibleV1 = await ethers.getContractFactory("CollectibleV1");
|
||||||
const ONE_YEAR_IN_SECS = 365 * 24 * 60 * 60;
|
const contract = await CollectibleV1.deploy(
|
||||||
const unlockTime = currentTimestampInSeconds + ONE_YEAR_IN_SECS;
|
"Test",
|
||||||
|
"TEST",
|
||||||
|
100,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
"http://local.dev"
|
||||||
|
);
|
||||||
|
|
||||||
const lockedAmount = ethers.utils.parseEther("1");
|
const instance = await contract.deployed();
|
||||||
|
const tx = instance.deployTransaction;
|
||||||
const Lock = await ethers.getContractFactory("Lock");
|
const rec = await tx.wait();
|
||||||
const lock = await Lock.deploy(unlockTime, { value: lockedAmount });
|
console.log("CollectibleV1 deployed. Gas used:", pn(rec.gasUsed));
|
||||||
|
|
||||||
await lock.deployed();
|
|
||||||
|
|
||||||
console.log(`Lock with 1 ETH and unlock timestamp ${unlockTime} deployed to ${lock.address}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We recommend this pattern to be able to use async/await everywhere
|
// We recommend this pattern to be able to use async/await everywhere
|
||||||
// and properly handle errors.
|
// and properly handle errors.
|
||||||
main().catch((error) => {
|
main().catch((error) => {
|
||||||
|
|
Loading…
Reference in New Issue