-
Notifications
You must be signed in to change notification settings - Fork 1
/
hardhat.config.ts
89 lines (80 loc) · 2.21 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
import '@nomiclabs/hardhat-waffle';
import '@typechain/hardhat';
import 'solidity-coverage';
import './tasks/accounts';
import './tasks/clean';
import { resolve } from 'path';
import { config as dotenvConfig } from 'dotenv';
import { HardhatUserConfig } from 'hardhat/config';
import { NetworkUserConfig } from 'hardhat/types';
dotenvConfig({ path: resolve(__dirname, './.env') });
const chainIds = {
ganache: 1337,
goerli: 5,
hardhat: 31337,
kovan: 42,
mainnet: 1,
rinkeby: 4,
ropsten: 3,
};
// Ensure that we have all the environment variables we need.
const privateKey = process.env.PRIVATE_KEY as string;
if (!privateKey) throw new Error('Please set your PRIVATE_KEY in a .env file');
const rpcUrl = process.env.RPC_URL as string;
if (!rpcUrl) throw new Error('Please set your RPC_URL in a .env file');
// Use the default hardhat mnemonic when on localhost
const mnemonic = 'test test test test test test test test test test test junk';
// Helper function to generate a hardhat network config
function createNetworkConfig(network: keyof typeof chainIds): NetworkUserConfig {
return {
accounts: [privateKey],
chainId: chainIds[network],
url: rpcUrl,
};
}
// Main hardhat configuration
const config: HardhatUserConfig = {
defaultNetwork: 'hardhat',
networks: {
hardhat: {
accounts: { mnemonic },
chainId: chainIds.hardhat,
initialBaseFeePerGas: 0,
forking: {
url: rpcUrl,
blockNumber: 13498819, // requires archive node data
},
},
mainnet: createNetworkConfig('mainnet'),
},
paths: {
artifacts: './artifacts',
cache: './cache',
sources: './contracts',
tests: './test',
},
mocha: {
timeout: 0,
},
solidity: {
version: '0.8.9',
settings: {
metadata: {
// Not including the metadata hash
// https://github.com/paulrberg/solidity-template/issues/31
bytecodeHash: 'none',
},
// You should disable the optimizer when debugging
// https://hardhat.org/hardhat-network/#solidity-optimizer-support
optimizer: {
enabled: true,
runs: 999999,
},
},
},
typechain: {
outDir: 'typechain',
target: 'ethers-v5',
},
};
export default config;