-
Notifications
You must be signed in to change notification settings - Fork 39
/
hardhat.config.js
53 lines (48 loc) · 1.35 KB
/
hardhat.config.js
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
require('@nomiclabs/hardhat-web3');
require('@nomiclabs/hardhat-ethers');
const ethers = require('ethers');
const providerUrl = process.env.MAINNET_PROVIDER_URL;
const developmentMnemonic = process.env.DEV_ETH_MNEMONIC;
if (!providerUrl) {
console.error('Missing JSON RPC provider URL as environment variable `MAINNET_PROVIDER_URL`\n');
process.exit(1);
}
if (!developmentMnemonic) {
console.error('Missing development Ethereum account mnemonic as environment variable `DEV_ETH_MNEMONIC`\n');
process.exit(1);
}
function getPrivateKeysFromMnemonic(mnemonic, numberOfPrivateKeys = 20) {
const result = [];
for (let i = 0; i < numberOfPrivateKeys; i++) {
result.push(ethers.Wallet.fromMnemonic(mnemonic, `m/44'/60'/0'/0/${i}`).privateKey);
}
}
module.exports = {
solidity: {
version: '0.8.6',
settings: {
optimizer: {
enabled: true,
runs: 1000
}
}
},
networks: {
hardhat: {
forking: {
url: providerUrl,
},
gasPrice: 0,
initialBaseFeePerGas: 0,
loggingEnabled: false,
accounts: {
mnemonic: developmentMnemonic,
},
chainId: 1, // metamask -> accounts -> settings -> networks -> localhost 8545 -> set chainId to 1
},
localhost: {
url: 'http://localhost:8545',
accounts: getPrivateKeysFromMnemonic(developmentMnemonic),
}
},
};