-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhardhat.config.js
More file actions
144 lines (136 loc) · 3.59 KB
/
hardhat.config.js
File metadata and controls
144 lines (136 loc) · 3.59 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
require("dotenv").config();
require("hardhat-abi-exporter");
require("hardhat-deploy");
require("hardhat-watcher");
require("hardhat-contract-sizer");
require("hardhat-docgen");
require("hardhat-gas-reporter");
require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-solhint");
require("@nomiclabs/hardhat-ethers");
require("@nomiclabs/hardhat-etherscan");
require("solidity-coverage");
require("./tasks/accounts");
const { removeConsoleLog } = require("hardhat-preprocessor");
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 mnemonic = process.env.MNEMONIC;
if (!mnemonic) {
throw new Error("Please set your MNEMONIC in a .env file");
}
const infuraApiKey = process.env.INFURA_API_KEY;
if (!infuraApiKey) {
throw new Error("Please set your INFURA_API_KEY in a .env file");
}
function getChainConfig(network) {
const url = "https://" + network + ".infura.io/v3/" + infuraApiKey;
return {
accounts: {
initialIndex: 0,
count: 10,
mnemonic,
path: "m/44'/60'/0'/0",
},
chainId: chainIds[network],
tags: (network === "mainnet" && ["production"]) || ["staging"],
url,
live: (network === "mainnet" && true) || false,
saveDeployments: true,
};
}
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: "0.8.6",
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts", // build
},
defaultNetwork: "hardhat",
networks: {
hardhat: {
accounts: {
mnemonic,
},
chainId: chainIds.hardhat,
// See https://github.com/sc-forks/solidity-coverage/issues/652
hardfork: process.env.CODE_COVERAGE ? "berlin" : "london",
forking: {
// forking is enabled only if FORKING_URL env is provided
enabled: !!process.env.FORKING_URL,
// URL should point to a node with archival data (Alchemy recommended)
url: process.env.FORKING_URL || "https://eth-mainnet.alchemyapi.io/v2/<key>",
// latest block is taken if FORKING_BLOCK env is not provided
blockNumber: (process.env.FORKING_BLOCK && parseInt(process.env.FORKING_BLOCK)) || 0,
},
tags: ["test", "local"],
},
localhost: {
url: "http://127.0.0.1:8545",
tags: ["local"],
},
goerli: getChainConfig("goerli"),
kovan: getChainConfig("kovan"),
rinkeby: getChainConfig("rinkeby"),
ropsten: getChainConfig("ropsten"),
mainnet: getChainConfig("mainnet"),
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},
abiExporter: {
path: "./abi",
clear: true,
flat: true,
only: [],
except: [],
spacing: 2,
},
preprocess: {
eachLine: removeConsoleLog(bre => bre.network.name !== "hardhat" && bre.network.name !== "localhost"),
},
gasReporter: {
currency: "EUR",
enabled: !!process.env.REPORT_GAS,
coinmarketcap: process.env.COINMARKETCAP_API_KEY,
outputFile: "gas-report.txt",
},
watcher: {
compilation: {
tasks: ["compile"],
files: ["./contracts"],
verbose: true,
},
},
contractSizer: {
alphaSort: true,
runOnCompile: false,
disambiguatePaths: false,
},
docgen: {
path: "./docs",
clear: true,
runOnCompile: false,
},
namedAccounts: {
deployer: {
default: 0, // take the first account as deployer
},
},
mocha: {
timeout: 60000,
},
};