1
+ import { config as dotenvConfig } from "dotenv" ;
2
+ import { resolve } from "path" ;
3
+ dotenvConfig ( { path : resolve ( __dirname , "./.env" ) } ) ;
4
+
5
+ import { HardhatUserConfig } from "hardhat/config" ;
6
+ import { NetworkUserConfig } from "hardhat/types" ;
7
+ import "./tasks/accounts" ;
8
+ import "./tasks/clean" ;
9
+
10
+ import "@nomiclabs/hardhat-waffle" ;
11
+ // import "@nomiclabs/hardhat-ethers";
12
+ import "hardhat-typechain" ;
13
+ import "solidity-coverage" ;
14
+
15
+ const chainIds = {
16
+ ganache : 1337 ,
17
+ goerli : 5 ,
18
+ hardhat : 31337 ,
19
+ kovan : 42 ,
20
+ mainnet : 1 ,
21
+ rinkeby : 4 ,
22
+ ropsten : 3 ,
23
+ } ;
24
+
25
+ // Ensure that we have all the environment variables we need.
26
+ let mnemonic : string ;
27
+ if ( ! process . env . MNEMONIC ) {
28
+ throw new Error ( "Please set your MNEMONIC in a .env file" ) ;
29
+ } else {
30
+ mnemonic = process . env . MNEMONIC ;
31
+ }
32
+
33
+ let infuraApiKey : string ;
34
+ if ( ! process . env . INFURA_API_KEY ) {
35
+ throw new Error ( "Please set your INFURA_API_KEY in a .env file" ) ;
36
+ } else {
37
+ infuraApiKey = process . env . INFURA_API_KEY ;
38
+ }
39
+
40
+ function createTestnetConfig ( network : keyof typeof chainIds ) : NetworkUserConfig {
41
+ const url : string = "https://" + network + ".infura.io/v3/" + infuraApiKey ;
42
+ return {
43
+ accounts : {
44
+ count : 10 ,
45
+ initialIndex : 0 ,
46
+ mnemonic,
47
+ path : "m/44'/60'/0'/0" ,
48
+ } ,
49
+ chainId : chainIds [ network ] ,
50
+ url,
51
+ } ;
52
+ }
53
+
54
+ const config : HardhatUserConfig = {
55
+ defaultNetwork : "hardhat" ,
56
+ networks : {
57
+ hardhat : {
58
+ chainId : chainIds . hardhat ,
59
+ } ,
60
+ goerli : createTestnetConfig ( "goerli" ) ,
61
+ kovan : createTestnetConfig ( "kovan" ) ,
62
+ rinkeby : createTestnetConfig ( "rinkeby" ) ,
63
+ ropsten : createTestnetConfig ( "ropsten" ) ,
64
+ } ,
65
+ paths : {
66
+ artifacts : "./artifacts" ,
67
+ cache : "./cache" ,
68
+ sources : "./contracts" ,
69
+ tests : "./test" ,
70
+ } ,
71
+ solidity : {
72
+ version : "0.6.10" ,
73
+ settings : {
74
+ // https://hardhat.org/hardhat-network/#solidity-optimizer-support
75
+ optimizer : {
76
+ enabled : true ,
77
+ runs : 200 ,
78
+ } ,
79
+ } ,
80
+ } ,
81
+ typechain : {
82
+ outDir : "typechain" ,
83
+ target : "ethers-v5" ,
84
+ } ,
85
+ } ;
86
+
87
+ export default config ;
0 commit comments