-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
151 lines (139 loc) · 5.27 KB
/
hardhat.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* eslint @typescript-eslint/no-non-null-assertion: ["off"] */
import dotenv from "dotenv";
dotenv.config();
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "@nomiclabs/hardhat-solhint";
import "solidity-coverage";
import "solidity-docgen";
import "hardhat-contract-sizer";
import "hardhat-abi-exporter";
import "hardhat-gas-reporter";
import "hardhat-tracer";
import "./scripts/tasks/generate-account";
const envs = process.env;
// Private keys can be set in `.env` file.
const ethereumMainnetKeys = envs.ETHEREUM_MAINNET_KEYS?.split(",") ?? [];
const ethereumTestnetKeys = envs.ETHEREUM_TESTNET_KEYS?.split(",") ?? [];
/*
* The solc compiler optimizer is disabled by default to keep the Hardhat stack traces' line numbers the same.
* To enable, set `RUN_OPTIMIZER` to `true` in the `.env` file.
*/
const optimizerRuns = ["true", "1"].includes(envs.RUN_OPTIMIZER ?? "") || ["true", "1"].includes(envs.REPORT_GAS ?? "");
const optimizerRunNum = envs.OPTIMIZER_RUN_NUM ? +envs.OPTIMIZER_RUN_NUM : 200;
const enableForking = ["true", "1"].includes(envs.FORKING ?? "");
const networkHardfork = enableForking ? envs.HARDFORK : envs.HARDFORK ? envs.HARDFORK : "cancun";
const serial = ["true", "1"].includes(envs.SERIAL ?? "");
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.28",
settings: {
viaIR: optimizerRuns,
optimizer: {
enabled: optimizerRuns,
runs: optimizerRunNum,
details: {
yulDetails: {
optimizerSteps: optimizerRuns ? "u" : undefined
}
}
},
// Set to "paris" for chains that do not support the `PUSH0` opcode, such as Polygon, etc.
evmVersion: "cancun"
}
}
// { version: "0.7.6" }
]
// overrides: { "contracts/Deployed.sol": { version: "0.8.21" } }
},
// defaultNetwork: "hardhat",
networks: {
hardhat: {
allowUnlimitedContractSize: !optimizerRuns,
accounts: {
accountsBalance: envs.ACCOUNT_BALANCE ?? "10000000000000000000000", // 10000 ETH.
count: envs.NUMBER_OF_ACCOUNTS ? +envs.NUMBER_OF_ACCOUNTS : 20
},
forking: {
url: envs.FORKING_URL ?? "",
enabled: enableForking
},
hardfork: networkHardfork
// Uncomment if "Error: cannot estimate gas; transaction may fail or may require manual gas limit...".
// gas: 3E7,
// gasPrice: 8E9
},
// Ethereum:
ethereum: {
chainId: 1,
url: envs.ETHEREUM_URL ?? "",
accounts: [...ethereumMainnetKeys]
},
sepolia: {
chainId: 11155111,
url: envs.SEPOLIA_URL ?? "",
accounts: [...ethereumTestnetKeys]
},
holesky: {
chainId: 17000,
url: envs.HOLESKY_URL ?? "",
accounts: [...ethereumTestnetKeys]
}
},
etherscan: {
/*
* This is not necessarily the same name that is used to define the network.
* To see the full list of supported networks, run `$ npx hardhat verify --list-networks`. The identifiers
* shown there are the ones that should be used as keys in the `apiKey` object.
*
* See the link for details:
* `https://hardhat.org/hardhat-runner/plugins/nomiclabs-hardhat-etherscan#multiple-api-keys-and-alternative-block-explorers`.
*/
apiKey: {
mainnet: envs.ETHERSCAN_API_KEY ?? "",
sepolia: envs.ETHERSCAN_API_KEY ?? "",
holesky: envs.ETHERSCAN_API_KEY ?? ""
}
},
gasReporter: {
enabled: envs.REPORT_GAS !== undefined,
excludeContracts: ["vendor/"],
// currency: "USD", // "CHF", "EUR", etc.
showMethodSig: true,
L1Etherscan: envs.ETHERSCAN_API_KEY ?? ""
},
docgen: {
pages: "files",
exclude: ["vendor/"]
},
contractSizer: {
except: ["mocks/", "vendor/"]
},
abiExporter: {
except: ["interfaces/", "mocks/", "vendor/"],
spacing: 4
},
mocha: {
timeout: 40000,
parallel: !serial
// bail: true // Aborts after the first failure.
}
};
// By default fork from the latest block.
if (envs.FORKING_BLOCK_NUMBER) config.networks!.hardhat!.forking!.blockNumber = +envs.FORKING_BLOCK_NUMBER;
// Extra settings for `hardhat-gas-reporter`.
if (envs.COINMARKETCAP_API_KEY) config.gasReporter!.coinmarketcap = envs.COINMARKETCAP_API_KEY;
if (envs.REPORT_GAS_TO_FILE === "md") {
config.gasReporter!.outputFile = "gas-report.md";
config.gasReporter!.reportFormat = "markdown";
config.gasReporter!.forceTerminalOutput = true;
config.gasReporter!.forceTerminalOutputFormat = "terminal";
}
if (envs.REPORT_GAS_TO_FILE === "json") {
config.gasReporter!.outputJSON = true;
config.gasReporter!.outputJSONFile = "gas-report.json";
config.gasReporter!.includeBytecodeInJSON = true;
}
export default config;