generated from SebaBau/Solidity-Hardhat-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.network.ts
119 lines (107 loc) · 2.4 KB
/
hardhat.network.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
import { config as dotenvConfig } from "dotenv";
import { resolve } from "path";
dotenvConfig({ path: resolve(__dirname, "./.env") });
import { HardhatUserConfig } from "hardhat/config";
let mnemonic: string;
if (!process.env.MNEMONIC) {
throw new Error("Please set your MNEMONIC in a .env file");
} else {
mnemonic = process.env.MNEMONIC;
}
let infuraApiKey: string;
if (!process.env.INFURA_API_KEY) {
throw new Error("Please set your INFURA_API_KEY in a .env file");
} else {
infuraApiKey = process.env.INFURA_API_KEY;
}
let alchemyUrl: string;
if (!process.env.ALCHEMY_URL) {
throw new Error("Please set your ALCHEMY_URL in a .env file");
} else {
alchemyUrl = process.env.ALCHEMY_URL;
}
const networks: HardhatUserConfig["networks"] = {
coverage: {
url: "http://127.0.0.1:8555",
blockGasLimit: 200000000,
allowUnlimitedContractSize: true,
},
localhost: {
chainId: 1337,
url: "http://127.0.0.1:8545",
allowUnlimitedContractSize: true,
},
};
if (alchemyUrl && process.env.FORK_ENABLED && mnemonic) {
networks.hardhat = {
chainId: 1,
forking: {
url: alchemyUrl,
},
accounts: {
mnemonic,
},
};
} else {
console.log(alchemyUrl, process.env.FORK_ENABLED, mnemonic);
networks.hardhat = {
allowUnlimitedContractSize: true,
mining: {
auto: true,
interval: 30000, // 30 sec per block
},
};
}
networks.matic = {
chainId: 137,
url: "https://rpc-mainnet.maticvigil.com",
accounts: {
mnemonic,
},
};
networks.mumbai = {
chainId: 80001,
url: "https://rpc-mumbai.maticvigil.com",
accounts: {
mnemonic,
},
};
networks.bsc = {
chainId: 56,
url: "https://bsc-dataseed.binance.org",
accounts: {
mnemonic,
},
};
networks.bscTestnet = {
chainId: 97,
url: "https://data-seed-prebsc-1-s1.binance.org:8545/",
accounts: {
mnemonic,
},
};
networks.kovan = {
url: `https://kovan.infura.io/v3/${infuraApiKey}`,
accounts: {
mnemonic,
},
};
networks.ropsten = {
url: `https://ropsten.infura.io/v3/${infuraApiKey}`,
accounts: {
mnemonic,
},
};
networks.rinkeby = {
url: `https://rinkeby.infura.io/v3/${infuraApiKey}`,
accounts: {
mnemonic,
},
};
networks.mainnet = {
url: `https://mainnet.infura.io/v3/${infuraApiKey}`,
accounts: {
mnemonic,
},
};
export default networks;