forked from Open-Attestation/token-registry
-
Notifications
You must be signed in to change notification settings - Fork 5
/
hardhat.config.ts
150 lines (143 loc) · 3.29 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
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
146
147
148
149
150
import { randomBytes } from "crypto";
import "@typechain/hardhat";
import "@nomiclabs/hardhat-ethers";
import "@nomicfoundation/hardhat-chai-matchers";
import "hardhat-watcher";
import "hardhat-gas-reporter";
import "solidity-coverage";
import "@nomiclabs/hardhat-etherscan";
import dotenv from "dotenv";
import { HardhatUserConfig, HttpNetworkUserConfig } from "hardhat/types";
import "./tasks";
dotenv.config();
const {
INFURA_APP_ID,
MNEMONIC,
DEPLOYER_PK,
COINMARKETCAP_API_KEY,
ETHERSCAN_API_KEY,
POLYGONSCAN_API_KEY,
STABILITY_API_KEY,
} = process.env;
const IS_CI_ENV = process.env.NODE_ENV === "ci";
if (!IS_CI_ENV && !INFURA_APP_ID) {
throw new Error("Infura key is not provided in env");
}
if (!IS_CI_ENV && !DEPLOYER_PK && !MNEMONIC) {
throw new Error("Provide at least either deployer private key or mnemonic in env");
}
const networkConfig: HttpNetworkUserConfig = {};
if (IS_CI_ENV) {
networkConfig.accounts = [`0x${randomBytes(32).toString("hex")}`];
} else if (DEPLOYER_PK) {
networkConfig.accounts = [DEPLOYER_PK];
} else {
networkConfig.accounts = {
mnemonic: MNEMONIC!,
};
}
const config: HardhatUserConfig = {
solidity: {
version: "0.8.9",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
outputSelection: {
"*": {
"*": ["storageLayout"],
},
},
},
},
typechain: {
outDir: "src/contracts",
alwaysGenerateOverloads: true,
},
watcher: {
test: {
tasks: ["compile", "test"],
files: ["./contracts", "./test"],
},
},
gasReporter: {
coinmarketcap: COINMARKETCAP_API_KEY,
currency: "USD",
},
etherscan: {
apiKey: {
/**
* Ethereum
*/
mainnet: ETHERSCAN_API_KEY!,
/**
* Polygon
*/
polygon: POLYGONSCAN_API_KEY!,
},
},
networks: {
/**
* Ethereum
*/
mainnet: {
...networkConfig,
url: `https://mainnet.infura.io/v3/${INFURA_APP_ID}`,
},
sepolia: {
...networkConfig,
url: "https://rpc.sepolia.org",
},
xdc: {
...networkConfig,
url: "https://erpc.xinfin.network",
},
xdcapothem: {
...networkConfig,
url: "https://erpc.apothem.network",
},
hederamainnet: {
...networkConfig,
url: "https://mainnet.hashio.io/api",
},
hederatestnet: {
...networkConfig,
url: "https://testnet.hashio.io/api",
},
stabilitytestnet: {
...networkConfig,
url: "https://free.testnet.stabilityprotocol.com",
},
stability: {
...networkConfig,
// To get a API key, visit https://portal.stabilityprotocol.com
url: `https://gtn.stabilityprotocol.com/zgt/${STABILITY_API_KEY}`,
},
/**
* Polygon
*/
polygon: {
...networkConfig,
url: "https://polygon-rpc.com",
// Comment line above and Uncomment line below if using Infura
// url: `https://polygon-mainnet.infura.io/v3/${INFURA_APP_ID}`,
},
amoy: {
...networkConfig,
url: `https://polygon-amoy.infura.io/v3/${INFURA_APP_ID}`,
},
/**
* Development
*/
hardhat: {
allowUnlimitedContractSize: true,
},
localhost: {
...networkConfig,
accounts: "remote",
url: "http://127.0.0.1:8545",
},
},
};
export default config;