-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhardhat.config.js
More file actions
92 lines (87 loc) · 3.18 KB
/
Copy pathhardhat.config.js
File metadata and controls
92 lines (87 loc) · 3.18 KB
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
require("@nomicfoundation/hardhat-ethers");
require("@openzeppelin/hardhat-upgrades"); // For upgradeable contracts
require("dotenv").config(); // To load .env variables
require("@nomicfoundation/hardhat-chai-matchers");
//added for coverage reports
require('solidity-coverage');
//added for gas reports
require('hardhat-gas-reporter');
require("hardhat-contract-sizer");
require("hardhat-storage-layout"); // For storage layout analysis
const BESU_LOCAL_PRIVATE_KEY_ENV = "BESU_LOCAL_PRIVATE_KEY";
function isBesuLocalNetworkSelected() {
const networkFlagIndex = process.argv.indexOf("--network");
return (
(networkFlagIndex !== -1 && process.argv[networkFlagIndex + 1] === "besu-local") ||
process.argv.includes("--network=besu-local")
);
}
function getBesuLocalAccounts() {
const privateKey = process.env[BESU_LOCAL_PRIVATE_KEY_ENV];
if (!privateKey && isBesuLocalNetworkSelected()) {
throw new Error(
`${BESU_LOCAL_PRIVATE_KEY_ENV} is required for --network besu-local. ` +
"Set it in your environment or copy .env.example to .env and fill the Besu local key."
);
}
return privateKey ? [privateKey] : [];
}
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: {
version: "0.8.24", // Ensure this matches your contract's pragma
settings: {
optimizer: {
enabled: true,
runs: process.env.OPT_RUNS ? Number(process.env.OPT_RUNS) : 100
},
viaIR: process.env.VIA_IR ? process.env.VIA_IR === 'true' : true, // Allow override via env
evmVersion: process.env.EVM_VERSION || 'paris'
},
},
hardhatStorageLayout: {
showInConsole: true,
outputFile: "storage-layout.json",
runOnCompile: true // Automatically run after compilation
},
contractSizer: {
alphaSort: true, // Sort contracts alphabetically
runOnCompile: true, // Automatically run after compilation
disambiguatePaths: false, // Don't show full path if contract name is unique
strict: false, // Don't throw an error if contracts exceed limit
outputFile: "contract-size-report.txt", // Output to a file
// Substring match: reports every active facet + the Diamond proxy/loupe set.
// (Previously pinned a stale list that included archived/optional facets.)
only: ["Facet", "Diamond"],
unit: "KiB" // Display in Kibibytes (KiB) or Bytes (B)
},
defaultNetwork: "hardhat",
networks: {
hardhat: {
hostname: "0.0.0.0",
allowUnlimitedContractSize: true,
blockGasLimit: 30000000
},
localhost: {
url: "http://127.0.0.1:8545",
},
"besu-local": {
url: process.env.BESU_LOCAL_RPC_URL || "http://127.0.0.1:8545",
// LOCAL-DEV-ONLY: set BESU_LOCAL_PRIVATE_KEY to the prefunded local Besu
// account from .env.example. Do not silently fall back when this network
// is selected, because besu-local can also point at a real node.
accounts: getBesuLocalAccounts(),
chainId: 1337,
gas: "auto",
gasPrice: 0,
},
},
gasReporter: {
enabled: process.env.REPORT_GAS === 'true',
reportFormat: "markdown",
outputFile: "gasReport.md"
//,
//forceTerminalOutput: false,
//forceTerminalOutputFormat: "terminal"
}
};