-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
206 lines (193 loc) · 6.48 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
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
import {NetworkNameMapping} from './utils/helpers';
import '@nomicfoundation/hardhat-chai-matchers';
import '@nomicfoundation/hardhat-toolbox';
import '@nomicfoundation/hardhat-ethers';
import '@typechain/hardhat';
import {config as dotenvConfig} from 'dotenv';
import ethers from 'ethers';
import 'hardhat-deploy';
import 'hardhat-gas-reporter';
import {extendEnvironment, HardhatUserConfig} from 'hardhat/config';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import type {NetworkUserConfig} from 'hardhat/types';
import {resolve} from 'path';
import 'solidity-coverage';
const dotenvConfigPath: string = process.env.DOTENV_CONFIG_PATH || './.env';
dotenvConfig({path: resolve(__dirname, dotenvConfigPath)});
if (!process.env.ALCHEMY_API_KEY) {
throw new Error('ALCHEMY_API_KEY in .env not set');
}
const apiUrls: NetworkNameMapping = {
mainnet: 'https://eth-mainnet.g.alchemy.com/v2/',
polygon: 'https://polygon-mainnet.g.alchemy.com/v2/',
polygonAmoy: 'https://polygon-amoy.g.alchemy.com/v2/',
optimism: 'https://opt-mainnet.g.alchemy.com/v2/',
base: 'https://base-mainnet.g.alchemy.com/v2/',
baseSepolia: 'https://base-sepolia.g.alchemy.com/v2/',
arbitrum: 'https://arb-mainnet.g.alchemy.com/v2/',
blast: 'https://blast-mainnet.g.alchemy.com/v2/',
zksync: 'https://zksync-mainnet.g.alchemy.com/v2/',
};
const networks: {[index: string]: NetworkUserConfig} = {
hardhat: {
chainId: 31337,
forking: {
url: `${
apiUrls[
process.env.HARDHAT_FORK_NETWORK
? process.env.HARDHAT_FORK_NETWORK
: 'mainnet'
]
}${process.env.ALCHEMY_API_KEY}`,
blockNumber: 18991870
},
},
mainnet: {
chainId: 1,
url: `${apiUrls.mainnet}${process.env.ALCHEMY_API_KEY}`,
},
polygon: {
chainId: 137,
url: `${apiUrls.polygon}${process.env.ALCHEMY_API_KEY}`,
},
polygonAmoy: {
chainId: 80002,
url: `${apiUrls.polygonAmoy}${process.env.ALCHEMY_API_KEY}`,
},
optimism: {
chainId: 10,
url: `${apiUrls.optimism}${process.env.ALCHEMY_API_KEY}`,
},
arbitrum: {
chainId: 42161,
url: `${apiUrls.arbitrum}${process.env.ALCHEMY_API_KEY}`,
},
base: {
chainId: 8453,
url: `${apiUrls.base}${process.env.ALCHEMY_API_KEY}`,
},
baseSepolia: {
chainId: 84532,
url: `${apiUrls.baseSepolia}${process.env.ALCHEMY_API_KEY}`,
},
blast: {
chainId: 81457,
url: `${apiUrls.blast}${process.env.ALCHEMY_API_KEY}`,
},
zksync: {
chainId: 324,
url: `${apiUrls.zksync}${process.env.ALCHEMY_API_KEY}`,
},
};
// Uses hardhats private key if none is set. DON'T USE THIS ACCOUNT FOR DEPLOYMENTS
const accounts = process.env.PRIVATE_KEY
? process.env.PRIVATE_KEY.split(',')
: ['0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'];
for (const network in networks) {
// special treatement for hardhat
if (network.startsWith('hardhat')) {
// add 20 more recognizable standard hardhat accounts for testing
accounts.push(...[
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
'0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d',
'0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a',
'0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6',
'0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a',
'0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba',
'0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e',
'0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356',
'0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97',
'0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6',
'0xf214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897',
'0x701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82',
'0xa267530f49f8280200edf313ee7af6b827f2a8bce2897751d06a843f644967b1',
'0x47c99abed3324a2707c28affff1267e45918ec8c3f20b8aa892e8b065d2942dd',
'0xc526ee95bf44d8fc405a158bb884d9d1238d99f0612e9f33d006bb0789009aaa',
'0x8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61',
'0xea6c44ac03bff858b476bba40716402b03e41b8e97e276d1baec7c37d42484a0',
'0x689af8efa8c651a91ad287602527f3af2fe9f6501a7ac4b061667b5a93e037fd',
'0xde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0',
'0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e',
])
networks[network].accounts = accounts.map(account => ({
privateKey: account,
balance: '100000000000000000000', // Set balance to 100 ETH
}));
continue;
}
networks[network].accounts = accounts;
}
const config: HardhatUserConfig = {
defaultNetwork: 'hardhat',
namedAccounts: {
deployer: 0,
},
networks,
paths: {
artifacts: './artifacts',
cache: './cache',
sources: './contracts',
tests: './test',
deploy: './deploy',
},
solidity: {
compilers: [
{
version: '0.8.17',
settings: {
metadata: {
// Not including the metadata hash
// https://github.com/paulrberg/hardhat-template/issues/31
bytecodeHash: 'none',
},
// Disable the optimizer when debugging
// https://hardhat.org/hardhat-network/#solidity-optimizer-support
optimizer: {
enabled: true,
runs: 1,
},
},
},
{
version: '0.8.20',
settings: {
metadata: {
// Not including the metadata hash
// https://github.com/paulrberg/hardhat-template/issues/31
bytecodeHash: 'none',
},
// Disable the optimizer when debugging
// https://hardhat.org/hardhat-network/#solidity-optimizer-support
optimizer: {
enabled: true,
runs: 1,
},
},
},
{
version: '0.8.8',
settings: {
metadata: {
// Not including the metadata hash
// https://github.com/paulrberg/hardhat-template/issues/31
bytecodeHash: 'none',
},
// Disable the optimizer when debugging
// https://hardhat.org/hardhat-network/#solidity-optimizer-support
optimizer: {
enabled: true,
runs: 1,
},
},
}
]
},
typechain: {
outDir: 'typechain',
target: 'ethers-v6',
},
mocha: {
timeout: 100000000
},
};
export default config;