-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
105 lines (98 loc) · 2.07 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
* Import libraries
*/
import dotenv from "dotenv";
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "tsconfig-paths/register";
import "@openzeppelin/hardhat-upgrades";
/**
* Config dotenv first
*/
dotenv.config();
/**
* Default hardhat configs
*/
const config: HardhatUserConfig = {
solidity: {
version: "0.8.16",
settings: {
optimizer: {
enabled: true,
runs: 2000,
},
},
},
};
/**
* Extract env vars
*/
const privateKey = process.env.PRIVATE_KEY || "";
const testEnv = process.env.ENV === "test";
/**
* If private key is available, attach network configs
*/
if (!testEnv && privateKey) {
config.networks = {
ganache: {
url: "http://127.0.0.1:7545",
chainId: 5777,
},
hardhat_local: {
url: "http://127.0.0.1:8545",
accounts: [privateKey],
gasPrice: 250000000000,
},
hardhat: {
forking: {
url: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_ID}`,
},
gas: "auto",
gasPrice: "auto",
chainId: 1,
},
rinkeby: {
url: `https://rinkeby.infura.io/v3/${process.env.INFURA_ID}`,
accounts: [privateKey],
chainId: 4,
},
mainnet: {
url: `https://mainnet.infura.io/v3/${process.env.INFURA_ID}`,
accounts: [privateKey],
gas: "auto",
gasPrice: "auto",
chainId: 1,
},
bsc_testnet: {
url: "https://data-seed-prebsc-1-s1.binance.org:8545",
accounts: [privateKey],
gas: "auto",
gasPrice: "auto",
chainId: 97,
},
bsc: {
url: "https://bsc-dataseed1.binance.org",
accounts: [privateKey],
gas: "auto",
gasPrice: "auto",
chainId: 56,
},
hamsterbox: {
url: "https://rpc.hamsterbox.xyz",
accounts: [privateKey],
gas: "auto",
gasPrice: 0,
chainId: 5722,
},
};
}
/**
* Load etherscan key
*/
const etherscanKey = process.env.ETHERSCAN_KEY || "";
if (etherscanKey) {
config.etherscan = {
apiKey: etherscanKey,
};
}
export default config;