Gas Usage Analytics for Hardhat
blobBaseFee
drops below 1 gwei by @cgewecke in https://github.com/cgewecke/hardhat-gas-reporter/pull/228
Full Changelog: https://github.com/cgewecke/hardhat-gas-reporter/compare/v2.1.0...v2.1.1
gasReporter: {
L2: "arbitrum" | "base" | "optimism",
L2Etherscan: "ABC....",
coinmarketcap: "abc...",
}
blobBaseFee
is now fetched directly from the OP stack GasOracle contracts (should be accurate)blobBaseFee
prices for L2 emulation you'll need to set the L2Etherscan
api key option.Full Changelog: https://github.com/cgewecke/hardhat-gas-reporter/compare/v2.0.2...v2.1.0
Full Changelog: https://github.com/cgewecke/hardhat-gas-reporter/compare/v2.0.1...v2.0.2
Full Changelog: https://github.com/cgewecke/hardhat-gas-reporter/compare/v2.0.0...v2.0.1
Configuration for chains with Etherscan support has been simplified to a single key. Just set the L1
option to one of the supported networks and the reporter will take care of the rest. (You'll still need a coinmarketcap api key)
gasReporter: {
L1: "gnosis",
coinmarketcap: "abc...",
}
Gas reporting for L2 networks is coming online, starting with Optimism.
gasReporter: {
L2: "optimism",
coinmarketcap: "abc...",
}
Gas metrics for view
and pure
methods are now available as an option. You can also exclude intrinsic gas costs for state-changing methods. (⚠️ There are performance hits when the view and pure options are enabled)
gasReporter: {
// Debits intrinsic gas for state-changing method calls in order to model contracts
// that will never be called by an EOA
includeIntrinsicGas: false,
// This option executes an additional `eth_estimateGas` for every `eth_call`
// detected by the reporter. If you have 1000's of tests setting it to true has a
// noticeable performance impact
reportPureAndViewMethods: true,
// This option can add SIGNIFICANT LAG to test startup time if you have
// 100's of contracts in your project. (It parses all the sources in your dependency tree
// to identify state variable declarations)
excludeAutoGeneratedGetters: true,
}
There are multiple report formats, including markdown.
The reporter now supports sub-gwei gas prices. Sub-penny cost display is possible by configuring the currencyDisplayPrecision
option
Dedicated support for the OpenZeppelin Upgrades plugin has been added. (Their proxy pattern often resulted in missing gas data because the reporter didn't know what contract was being called - that's all handled under the hood now.)
Dedicated support for the hardhat-viem plugin has been added (this was broken and should be fixed by this release)
There are many new output, display and low-level options - check out the Config Examples section of the docs
There's additional support for custom proxy contract resolution. If you're routing your calls through contract middleware you can configure the reporter to understand how that works and get the data you expect.
Additionally:
gas-reporter:merge
task has been renamed hhgas:merge
onlyCalledMethods
option has been renamed showUncalledMethods
and must be set to true
(if you want that).Work on V2 was funded in part by OpenZeppelin via DRIPS, a public goods protocol that helps direct funding to packages in your dependency tree. If you're using DRIPS and want to add hardhat-gas-reporter to the packages you support its page is here.
Full Changelog: https://github.com/cgewecke/hardhat-gas-reporter/compare/v1.10.0...v2.0.0
Full Changelog: https://github.com/cgewecke/hardhat-gas-reporter/compare/v1.0.9...v1.10.0
This pre-release contains a work-around patch to make the gas reporter work with Hardhat's viem
tooling. It can be installed with:
npm install --save-dev hardhat-gas-reporter@viem
⚠️ Important: for the plugin to work correctly, it must be listed before the hardhat-viem
plugin in hardhat.config.ts
e.g
import "hardhat-gas-reporter" // <--- first
import "@nomicfoundation/hardhat-toolbox-viem"
There is ongoing work to make this part of the normally published package in #167 but it will not be released until v2.0 (probably end of February at the earliest).
Full Changelog: https://github.com/cgewecke/hardhat-gas-reporter/compare/v1.0.8...v1.0.9