forked from defi-org-code/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.ts
93 lines (88 loc) · 2.55 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
import "dotenv/config";
import { HardhatUserConfig, task } from "hardhat/config";
import "@typechain/hardhat";
import "@nomiclabs/hardhat-web3";
import "@nomiclabs/hardhat-etherscan";
import "hardhat-tracer";
import "hardhat-gas-reporter";
import "hardhat-spdx-license-identifier";
import { account, bn18, erc20s, ether, networks, web3 } from "@defi.org/web3-candies";
import { deploy } from "@defi.org/web3-candies/dist/hardhat/deploy";
task("deploy").setAction(async () => {
console.log("deploying example Greeter contract:");
const ac = web3().eth.accounts.create();
console.log("pk:", ac.privateKey);
await web3().eth.sendTransaction({ from: await account(), to: ac.address, value: ether });
await deploy("Greeter", ["Hello, world!"], 5_000_000, 0, true, 1);
});
process.env.NETWORK = process.env.NETWORK?.toUpperCase() || "ETH";
console.log(`🌐 network`, process.env.NETWORK, "blocknumber", process.env.BLOCK, "🌐");
export default {
solidity: {
version: "0.8.10",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
defaultNetwork: "hardhat",
networks: {
hardhat: {
forking: {
blockNumber: process.env.BLOCK ? parseInt(process.env.BLOCK!) : undefined,
url: (process.env as any)[`NETWORK_URL_${process.env.NETWORK}`] || "",
},
blockGasLimit: 10e6,
accounts: {
accountsBalance: bn18(10e6).toString(),
},
},
eth: {
chainId: networks.eth.id,
url: process.env.NETWORK_URL_ETH || "",
},
bsc: {
chainId: networks.bsc.id,
url: process.env.NETWORK_URL_BSC || "",
},
poly: {
chainId: networks.poly.id,
url: process.env.NETWORK_URL_POLY || "",
},
avax: {
chainId: networks.avax.id,
url: process.env.NETWORK_URL_AVAX || "",
},
},
typechain: {
outDir: "typechain-hardhat",
target: "web3-v1",
},
mocha: {
timeout: 180_000,
retries: 0,
bail: true,
},
gasReporter: {
currency: "USD",
coinmarketcap: process.env.COINMARKETCAP,
token: gasReporter().token,
gasPriceApi: gasReporter().url,
showTimeSpent: true,
},
etherscan: {
apiKey: process.env[`ETHERSCAN_${process.env.NETWORK}`],
},
} as HardhatUserConfig;
function gasReporter() {
switch (process.env.NETWORK) {
case "AVAX":
return { token: "AVAX", url: "https://api.snowtrace.io/api?module=proxy&action=eth_gasPrice" };
case "POLY":
return { token: "MATIC", url: "https://api.polygonscan.com/api?module=proxy&action=eth_gasPrice" };
default:
return {};
}
}