generated from wighawag/template-ethereum-contracts
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathhardhat.config.ts
122 lines (114 loc) · 2.79 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
import "dotenv/config";
import "hardhat-deploy";
import "hardhat-deploy-ethers";
import { HardhatUserConfig } from "hardhat/types";
import "solidity-coverage";
import "@nomiclabs/hardhat-etherscan";
import "@symfoni/hardhat-react";
import "hardhat-gas-reporter";
// * due to auto-generation the tests run much slower
// * unless this becomes opt-in, remove the comment out
// * to generate the new types
// * relating github issue: https://github.com/rhlsthrm/hardhat-typechain/issues/12
import "hardhat-typechain";
import "@typechain/ethers-v5";
function node_url(networkName: string): string {
if (networkName) {
const uri = process.env["ETH_NODE_URI_" + networkName.toUpperCase()];
if (uri && uri !== "") {
return uri;
}
}
let uri = process.env.ETH_NODE_URI;
if (uri) {
uri = uri.replace("{{networkName}}", networkName);
}
if (!uri || uri === "") {
// throw new Error(`environment variable "ETH_NODE_URI" not configured `);
return "";
}
if (uri.indexOf("{{") >= 0) {
throw new Error(
`invalid uri or network not supported by nod eprovider : ${uri}`
);
}
return uri;
}
function getMnemonic(networkName?: string): string {
if (networkName) {
const mnemonic = process.env["MNEMONIC_" + networkName.toUpperCase()];
if (mnemonic && mnemonic !== "") {
return mnemonic;
}
}
const mnemonic = process.env.MNEMONIC;
if (!mnemonic || mnemonic === "") {
return "test test test test test test test test test test test junk";
}
return mnemonic;
}
function accounts(networkName?: string): { mnemonic: string } {
return { mnemonic: getMnemonic(networkName) };
}
const config: HardhatUserConfig = {
solidity: {
version: "0.8.6",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
namedAccounts: {
deployer: 0,
beneficiary: 1,
lender: 2,
renter: 3,
},
networks: {
kovan: {
url: node_url("kovan"),
accounts: accounts(),
gas: 6_000_000,
},
rinkeby: {
url: node_url("rinkeby"),
accounts: accounts(),
gas: 6_000_000,
},
ropsten: {
url: node_url("ropsten"),
accounts: accounts(),
gas: 6_000_000,
},
goerli: {
url: node_url("goerli"),
accounts: accounts(),
gas: 6_000_000,
gasPrice: 50000000000,
},
hardhat: {
accounts: accounts(),
},
localhost: {
url: "http://localhost:8545",
accounts: accounts(),
},
// mainnet: {
// url: "https://eth-mainnet.alchemyapi.io/v2/<apiKey>",
// // to have a private key, just pass it in an array like so: ["0xprivKey"]
// accounts: ["<privKey>"],
// },
},
paths: {
sources: "src",
},
mocha: {
timeout: 0,
},
gasReporter: {
currency: "USD",
},
};
export default config;