hardhat-gas-reporter
eth-gas-reporter plugin for hardhat. :fuelpump:
What
A Mocha reporter for Ethereum test suites:
- Gas usage per unit test.
- Metrics for method calls and deployments.
- National currency costs of deploying and using your contract system.
- CI integration with codechecksbeta
Example report
Installation
npm install hardhat-gas-reporter --save-dev
And add the following to your hardhat.config.js
:
require("hardhat-gas-reporter");
Or, if you are using TypeScript, add this to your hardhat.config.ts:
import "hardhat-gas-reporter"
Looking for buidler-gas-reporter docs? They moved here...
Configuration
Configuration is optional.
module.exports = {
gasReporter: {
currency: 'CHF',
gasPrice: 21
}
}
:bulb: Pro Tip
The options include an enabled
key that lets you toggle gas reporting on and off using shell
environment variables. When enabled
is false, mocha's (faster) default spec reporter is used.
Example:
module.exports = {
gasReporter: {
enabled: (process.env.REPORT_GAS) ? true : false
}
}
Usage
This plugin overrides the built-in test
task. Gas reports are generated by default with:
npx hardhat test
Options / Documentation
A list of options and other useful documentation can be found at eth-gas-reporter