hardhat-gas-reporter icon indicating copy to clipboard operation
hardhat-gas-reporter copied to clipboard

Feature Request: Include sum of deployment gas in output

Open wattsyart opened this issue 1 year ago • 2 comments

I'm routinely "gas golfing" large projects, and one thing I always need to do is dump out the gas report and manually sum it to get a total gas cost for every deployed contract to check if the experiment is reducing overall cost or not.

I can emit to a file and use regex to do this, but it would be nice to include a configuration switch that adds the total deployment gas usage to the output itself.

wattsyart avatar Jul 25 '22 21:07 wattsyart

Indeeed, it would be a great addition!! Have you found a workaround? besides scripting?

andreujuanc avatar Aug 26 '22 10:08 andreujuanc

@andreujuanc No workaround besides custom scripting, unfortunately.

I wrote a hardhat task for my project that:

  • uses a canned hardhat-gas-reporter console output saved to /scripts/lastOutput.txt
  • builds a new table showing cost per category and the estimated gas cost at n gwei similar to this: https://github.com/wattsyart/cryptoadz-chained/wiki/Gas-Cost-Report

Code is here: https://github.com/wattsyart/cryptoadz-chained/blob/main/tasks/tasks.js#L171

wattsyart avatar Aug 26 '22 20:08 wattsyart