-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhardhat.config.js
70 lines (68 loc) · 2.33 KB
/
hardhat.config.js
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
require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-ethers");
require("@nomiclabs/hardhat-ganache");
require("dotenv").config();
require("hardhat-gas-reporter");
require("hardhat-abi-exporter");
require("hardhat-deploy");
require("hardhat-docgen");
// Custom task to print the balance of an account
task("balance", "Prints an account's balance", async (taskArgs, hre) => {
const { ethers } = hre;
const balance = await ethers.provider.getBalance(taskArgs.account);
console.log(ethers.utils.formatEther(balance), "ETH");
}).addParam("account", "The account's address");
// Hardhat configuration
module.exports = {
solidity: {
version: "0.8.4", // Specify the Solidity version
settings: {
optimizer: {
enabled: true,
runs: 200, // Optimize for how many times you intend to run the code
},
},
},
networks: {
hardhat: {
chainId: 1337, // Default Hardhat network chain ID
},
localhost: {
url: "http://127.0.0.1:8545",
accounts: [process.env.PRIVATE_KEY], // Use the private key from .env
},
ropsten: {
url: process.env.ROPSTEN_URL, // Infura or Alchemy URL for Ropsten
accounts: [process.env.PRIVATE_KEY],
gas: 5000000,
gasPrice: 20000000000, // 20 gwei
},
mainnet: {
url: process.env.MAINNET_URL, // Infura or Alchemy URL for Mainnet
accounts: [process.env.PRIVATE_KEY],
gas: 5000000,
gasPrice: 20000000000, // 20 gwei
},
},
gasReporter: {
enabled: true,
currency: "USD",
gasPrice: 21, // Set gas price in gwei
outputFile: "gas-report.txt",
noColors: true,
},
abiExporter: {
path: './abi', // Output directory for ABI files
clear: true, // Clear the output directory before exporting
flat: true, // Export all ABIs into a single file
only: [":MyContract$"], // Only export specific contracts
},
docgen: {
path: "./docs", // Output directory for documentation
clear: true, // Clear the output directory before generating
runOnCompile: true, // Generate docs on every compile
},
mocha: {
timeout: 20000, // Set timeout for tests
},
};