generated from turbo-eth/template-hardhat-sol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.network.ts
145 lines (127 loc) · 3.97 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
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
145
import { HardhatUserConfig } from 'hardhat/config';
import { HardhatNetworkAccountUserConfig } from 'hardhat/types';
// 🔐 Accounts
const MNEMONIC =
process.env.MNEMONIC || 'test test test test test test test test test test test junk';
const TESTNET_PK_DEPLOYER = process.env.TESTNET_PK_DEPLOYER || ('' as string);
const MAINNET_PK_DEPLOYER = process.env.MAINNET_PK_DEPLOYER || ('' as string);
// ⚪ Ethereum
const ETHEREUM_MAINNET_RPC_URL = process.env.ETHEREUM_MAINNET_RPC_URL;
const ETHEREUM_GOERLI_RPC_URL = process.env.ETHEREUM_GOERLI_RPC_URL;
// 🟣 Polygon
const POLYGON_MAINNET_RPC_URL = process.env.POLYGON_MAINNET_RPC_URL;
const POLYGON_TESTNET_RPC_URL = process.env.POLYGON_TESTNET_RPC_URL;
// 🔴 Optimism
const OPTIMISM_MAINNET_RPC_URL = process.env.OPTIMISM_MAINNET_RPC_URL;
const OPTIMISM_TESTNET_RPC_URL = process.env.OPTIMISM_TESTNET_RPC_URL;
// 🔵 Base
const BASE_MAINNET_RPC_URL = process.env.BASE_MAINNET_RPC_URL;
const BASE_TESTNET_RPC_URL = process.env.BASE_TESTNET_RPC_URL;
// ⛓️ Forking
const ARCHIVE_NODE_RPC_URL = process.env.ARCHIVE_NODE_RPC_URL;
const FORK_ENABLED = process.env.FORK_ENABLED;
const FORK_BLOCK_NUMBER = process.env.FORK_BLOCK_NUMBER;
/* ===================================================================================== */
/* Local */
/* ===================================================================================== */
const networks: HardhatUserConfig['networks'] = {
coverage: {
url: 'http://127.0.0.1:8555',
blockGasLimit: 200000000,
allowUnlimitedContractSize: true,
},
localhost: {
chainId: 1,
url: 'http://127.0.0.1:8545',
},
};
/* ===================================================================================== */
/* Fork */
/* ===================================================================================== */
if (ARCHIVE_NODE_RPC_URL && FORK_ENABLED) {
networks.hardhat = {
chainId: 1,
hardfork: 'istanbul',
forking: {
url: ARCHIVE_NODE_RPC_URL,
blockNumber: Number(FORK_BLOCK_NUMBER || '0'),
},
};
} else {
networks.hardhat = {
allowUnlimitedContractSize: true,
accounts: { mnemonic: MNEMONIC },
};
}
/* ===================================================================================== */
/* External */
/* ===================================================================================== */
/**
* Ethereum
* @mainnet: 1
* @testnet: 5
*/
if (MAINNET_PK_DEPLOYER && ETHEREUM_MAINNET_RPC_URL) {
networks.mainnet = {
url: ETHEREUM_MAINNET_RPC_URL,
chainId: 1,
accounts: [MAINNET_PK_DEPLOYER],
};
}
if (TESTNET_PK_DEPLOYER && ETHEREUM_GOERLI_RPC_URL) {
networks.goerli = {
url: ETHEREUM_GOERLI_RPC_URL,
accounts: [TESTNET_PK_DEPLOYER],
};
}
/**
* Optimism
* @mainnet: 10
* @testnet: 420
*/
if (MAINNET_PK_DEPLOYER && OPTIMISM_MAINNET_RPC_URL) {
networks.optimism = {
url: OPTIMISM_MAINNET_RPC_URL,
chainId: 10,
accounts: [MAINNET_PK_DEPLOYER],
};
}
if (TESTNET_PK_DEPLOYER && OPTIMISM_TESTNET_RPC_URL) {
networks.optimismTestnet = {
url: OPTIMISM_TESTNET_RPC_URL,
chainId: 420,
accounts: [TESTNET_PK_DEPLOYER],
};
}
/**
* Polygon
* @mainnet: 137
* @testnet: 80001
*/
if (MAINNET_PK_DEPLOYER && POLYGON_MAINNET_RPC_URL) {
networks.polygon = {
url: POLYGON_MAINNET_RPC_URL,
chainId: 137,
accounts: [MAINNET_PK_DEPLOYER],
};
}
if (TESTNET_PK_DEPLOYER && POLYGON_TESTNET_RPC_URL) {
networks.polygonTestnet = {
url: POLYGON_TESTNET_RPC_URL,
chainId: 80001,
accounts: [TESTNET_PK_DEPLOYER],
};
}
/**
* Base
* @mainnet:
* @testnet: 84531
*/
if (TESTNET_PK_DEPLOYER && BASE_TESTNET_RPC_URL) {
networks.baseTestnet = {
url: BASE_TESTNET_RPC_URL,
chainId: 84531,
accounts: [TESTNET_PK_DEPLOYER],
};
}
export default networks;