I've learned from this question that it is not (always) possible to compute the gas-costs of an arbitrary solidity contract a.sol because the amount of computation that it takes may depend on the input it receives from the other smart contracts that it interacts with.

However, in for example the HardHat or Waffle test framework, one can feed your smart contract a.sol, all of its other smart contracts. Yet I did not yet find a clear indication of the gas costs of that contract. (After the tests were completed, before it was deployed to main-net).

So, assuming one has enough coverage in the tests (contracts), one could get an accurate enough range of the gas costs as a function of various input (test) contracts.


Are there applications/code solutions (in HardHat) that instantly give the gas costs of a contract based on specific input contracts? (Ideally, a minimal working example (MWE) of parameterised plot based on certain input variables could be presented).

  • I think eth-gas-reporter has some functionality like this, check it out. I don't remember exactly which statistics it gives you, but it might be what you want. Nov 11, 2021 at 15:20
  • 1
    Could you use a mainnet fork and deploy the contract to it and test the gas costs? This should be quite accurate on mainnet at least.
    – Richard
    Jan 3, 2022 at 11:35

1 Answer 1


I would suggest Remix IDE for such aim. It provides rich UI to compile, deploy and run the contract. In console it publish relevant information from EVM including gas cost on deploy and transaction.

  • Thank you for your suggestion, it is definitely better than nothing. From what I understand, I do think it misses the automated aspect a bit as I believe the IDE/UI is not a command line interface. If this assumption is invalid, please let me know.
    – a.t.
    Aug 18, 2022 at 3:43
  • 1
    Hardhat support gas reporting 'out of the box'. Here is the command REPORT_GAS=true npx hardhat test
    – Gleichmut
    Aug 20, 2022 at 4:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.