-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathhardhat.config.js
More file actions
379 lines (373 loc) · 11.7 KB
/
hardhat.config.js
File metadata and controls
379 lines (373 loc) · 11.7 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
/** @type import('hardhat/config').HardhatUserConfig */
// Env loading (runs before `networks` — independent of `--network`):
// - If process.env.ENV_FILE is set (shell), only that file is loaded into process.env.
// - Else if root `.env` exists and defines ENV_FILE=..., only that target file is loaded
// (`.env` is parsed for ENV_FILE only — other keys in `.env` are NOT applied).
// - Else load default `.env` as usual.
// `--network abstract_testnet` does NOT switch ENV_FILE; root `.env` may still point at e.g. bsc_testnet.
// Override per command: ENV_FILE=.env.launchpadv5_dev_abstract_testnet npx hardhat verify ... --network abstract_testnet
// Usage: put `ENV_FILE=.env.launchpadv5_local` in `.env`, or `ENV_FILE=.env.launchpadv5_local npx hardhat ...`
const fs = require("fs");
const path = require("path");
const dotenv = require("dotenv");
const projectRoot = __dirname;
const rootDotEnv = path.join(projectRoot, ".env");
function resolveEnvPath(p) {
const s = (p || "").trim();
if (!s) return null;
return path.isAbsolute(s) ? s : path.join(projectRoot, s);
}
let target = process.env.ENV_FILE?.trim() || null;
if (!target && fs.existsSync(rootDotEnv)) {
const parsed = dotenv.parse(fs.readFileSync(rootDotEnv, "utf8"));
target = (parsed.ENV_FILE || "").trim() || null;
}
if (target) {
const resolved = resolveEnvPath(target);
if (!resolved || !fs.existsSync(resolved)) {
throw new Error(
`ENV_FILE "${target}" resolved to missing path: ${resolved || "(empty)"}`
);
}
dotenv.config({ path: resolved });
console.log(`Loaded env file: ${resolved}`);
} else if (fs.existsSync(rootDotEnv)) {
dotenv.config({ path: rootDotEnv });
console.log(`Loaded env file: ${rootDotEnv}`);
} else {
dotenv.config(); // cwd `.env`, same as dotenv default
console.log("Loaded env via dotenv default (cwd .env if present)");
}
require("@nomicfoundation/hardhat-toolbox");
require("hardhat-deploy");
require("@openzeppelin/hardhat-upgrades");
require("@fireblocks/hardhat-fireblocks");
require("hardhat-contract-sizer");
const { ApiBaseUrl } = require("@fireblocks/fireblocks-web3-provider");
module.exports = {
solidity: {
version: "0.8.26",
settings: {
viaIR: true,
optimizer: {
enabled: true,
runs: 200,
},
},
},
overrides: {
"contracts/genesis/FGenesis.sol": {
version: "0.8.26",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
viaIR: false,
},
},
"contracts/genesis/Genesis.sol": {
version: "0.8.26",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
viaIR: false,
},
},
"contracts/launchpadv2/BondingV2.sol": {
version: "0.8.26",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
viaIR: false,
},
},
"contracts/launchpadv2/BondingV4.sol": {
version: "0.8.26",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
viaIR: false,
},
},
"contracts/launchpadv2/BondingV5.sol": {
version: "0.8.26",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
viaIR: false,
},
},
},
namedAccounts: {
deployer: `privatekey://${process.env.PRIVATE_KEY}`,
},
etherscan: {
// Etherscan API V2 (single key, multichain via chainid): https://docs.etherscan.io/v2-migration
// Do not use legacy api.basescan.org/api — Hardhat-verify reports deprecated V1 / log fetch failures.
apiKey: process.env.ETHERSCAN_API_KEY,
customChains: [
{
network: "base",
chainId: 8453,
urls: {
apiURL: "https://api.etherscan.io/v2/api",
browserURL: "https://basescan.org/",
},
},
{
network: "base_sepolia",
chainId: 84532,
urls: {
apiURL: "https://api.etherscan.io/v2/api",
browserURL: "https://sepolia.basescan.org/",
},
},
// Abstract L2 — https://docs.abs.xyz/build-on-abstract/smart-contracts/hardhat/verifying-contracts
{
network: "abstract_testnet",
chainId: 11124,
urls: {
apiURL: "https://api.etherscan.io/v2/api",
browserURL: "https://sepolia.abscan.org/",
},
},
{
network: "abstract_mainnet",
chainId: 2741,
urls: {
apiURL: "https://api.etherscan.io/v2/api",
browserURL: "https://abscan.org/",
},
},
// Monad — https://docs.monad.xyz/guides/verify-smart-contract/hardhat
// MonadScan uses Etherscan v2 (api.etherscan.io; Hardhat passes chainid). Monad Vision uses Sourcify
// (see scripts/launchpadv5/utils.ts verifyContract for monad_* networks).
{
network: "monad_testnet",
chainId: 10143,
urls: {
apiURL: "https://api.etherscan.io/v2/api",
browserURL: "https://testnet.monadscan.com/",
},
},
{
network: "monad_mainnet",
chainId: 143,
urls: {
apiURL: "https://api.etherscan.io/v2/api",
browserURL: "https://monadscan.com/",
},
},
{
network: "arbitrum_sepolia",
chainId: 421614,
urls: {
apiURL: "https://api.etherscan.io/v2/api",
browserURL: "https://sepolia.arbiscan.io/",
},
},
],
},
// Do not set a global Monad Sourcify URL here: `verify` would send every chain’s chainId to that server.
// Monad Sourcify is applied only in `scripts/launchpadv5/utils.ts` when network is monad_*.
sourcify: {
enabled: false,
},
networks: {
eth_mainnet: {
url: process.env.ETH_MAINNET_RPC_URL || "https://eth.drpc.org",
accounts: [process.env.PRIVATE_KEY],
},
sepolia: {
url: process.env.SEPOLIA_RPC_URL || "https://sepolia.drpc.org",
accounts: [process.env.PRIVATE_KEY],
},
eth_sepolia: {
url: process.env.ETH_SEPOLIA_RPC_URL || "https://sepolia.drpc.org",
accounts: [process.env.PRIVATE_KEY],
},
bsc_mainnet: {
url:
process.env.BSC_RPC_URL ||
process.env.RPC_URL ||
"https://bsc.drpc.org",
accounts: [process.env.PRIVATE_KEY],
chainId: 56,
},
bsc_testnet: {
url:
process.env.BSC_TESTNET_RPC_URL ||
process.env.RPC_URL ||
"https://bsc-testnet.drpc.org",
accounts: [process.env.PRIVATE_KEY],
chainId: 97,
},
// Abstract L2 testnet (see https://docs.abs.xyz/connect-to-abstract)
abstract_testnet: {
url:
process.env.ABSTRACT_TESTNET_RPC_URL ||
process.env.RPC_URL ||
"https://api.testnet.abs.xyz",
accounts: [process.env.PRIVATE_KEY],
chainId: 11124,
},
// Abstract L2 mainnet (see https://docs.abs.xyz/connect-to-abstract)
abstract_mainnet: {
url:
process.env.ABSTRACT_MAINNET_RPC_URL ||
process.env.RPC_URL ||
"https://api.mainnet.abs.xyz",
accounts: [process.env.PRIVATE_KEY],
chainId: 2741,
},
monad_testnet: {
url:
process.env.MONAD_TESTNET_RPC_URL ||
process.env.RPC_URL ||
"https://testnet-rpc.monad.xyz",
accounts: [process.env.PRIVATE_KEY],
chainId: 10143,
},
monad_mainnet: {
url:
process.env.MONAD_MAINNET_RPC_URL ||
process.env.RPC_URL ||
"https://mainnet.monad.xyz",
accounts: [process.env.PRIVATE_KEY],
chainId: 143,
},
base: {
url:
process.env.BASE_RPC_URL ||
process.env.RPC_URL ||
"https://mainnet.base.org",
accounts: [process.env.PRIVATE_KEY],
},
base_fire: {
url: "https://mainnet.base.org",
accounts: [process.env.PRIVATE_KEY],
fireblocks: {
privateKey: process.env.FIREBLOCKS_API_PRIVATE_KEY_PATH,
apiKey: process.env.FIREBLOCKS_API_KEY,
vaultAccountIds: process.env.FIREBLOCKS_VAULT_ACCOUNT_IDS,
},
},
base_sepolia: {
url:
process.env.BASE_SEPOLIA_RPC_URL ||
process.env.RPC_URL ||
"https://base-sepolia.drpc.org",
accounts: [process.env.PRIVATE_KEY],
},
// Do not fall back to RPC_URL — it often points at another chain (e.g. mainnet) in shared .env files.
arbitrum_sepolia: {
url:
process.env.ARBITRUM_SEPOLIA_RPC_URL ||
"https://sepolia-rollup.arbitrum.io/rpc",
accounts: [process.env.PRIVATE_KEY],
chainId: 421614,
},
base_sepolia_fire: {
url: "https://sepolia.base.org",
accounts: [process.env.PRIVATE_KEY],
fireblocks: {
apiBaseUrl: ApiBaseUrl.Sandbox,
privateKey: process.env.FIREBLOCKS_API_PRIVATE_KEY_PATH,
apiKey: process.env.FIREBLOCKS_API_KEY,
vaultAccountIds: process.env.FIREBLOCKS_VAULT_ACCOUNT_IDS,
},
},
local: {
url: "http://127.0.0.1:8545",
// Forked `hardhat node`: use PRIVATE_KEY so deployer matches the address that holds
// tokens on the forked chain (default Hardhat account #0 is usually empty on real forks).
...(process.env.PRIVATE_KEY
? { accounts: [process.env.PRIVATE_KEY] }
: {}),
// For forked node: npx hardhat node --fork <rpc_url> [--fork-block-number <n>]
},
// Fork RPC:
// - `npx hardhat node --fork <url>`: Hardhat uses that URL. Nothing below overrides it.
// - `npx hardhat test --network hardhat` with FORK_ENABLED=true: uses `forking.url` here
// (no separate node; no --fork on the CLI).
hardhat: {
// // Test-only: BondingV5 implementation currently exceeds EIP-170 size limit.
// // Keep production networks constrained; only relax in local hardhat runtime.
// allowUnlimitedContractSize: true,
forking: {
// Prefer FORK_RPC_URL when set. `run_local_deploy.sh --network local` requires FORK_RPC_URL in the env file.
url:
process.env.FORK_RPC_URL ||
process.env.BASE_SEPOLIA_RPC_URL ||
"https://base-sepolia.drpc.org",
enabled: process.env.FORK_ENABLED === "true",
// Omit blockNumber → Hardhat uses latest block from the fork RPC.
// Set FORK_BLOCK_NUMBER only when you need a pinned height (reproducible state).
...(process.env.FORK_BLOCK_NUMBER
? { blockNumber: parseInt(process.env.FORK_BLOCK_NUMBER, 10) }
: {}),
},
// Don't restrict accounts for hardhat network - use default 20 test accounts
// This ensures tests have enough signers available
// `chains` is the local EVM hardfork schedule, not “which RPC”. Hardhat reads chainId
// from the fork, but execution still needs a known activation history for some networks;
// add an entry here only if you hit that error (see Hardhat “chains” docs).
chains: {
84532: {
hardforkHistory: {
cancun: 0,
},
},
97: {
hardforkHistory: {
cancun: 0,
},
},
11124: {
hardforkHistory: {
cancun: 0,
},
},
2741: {
hardforkHistory: {
cancun: 0,
},
},
10143: {
hardforkHistory: {
cancun: 0,
},
},
421614: {
hardforkHistory: {
cancun: 0,
},
},
},
},
polygon: {
url: "https://rpc-mainnet.maticvigil.com/",
accounts: [process.env.PRIVATE_KEY],
},
mumbai: {
url: "https://rpc.ankr.com/polygon_mumbai",
accounts: [process.env.PRIVATE_KEY],
},
goerli: {
url: "https://rpc.ankr.com/eth_goerli",
accounts: [process.env.PRIVATE_KEY],
},
},
mocha: {
timeout: 100000000,
},
};