Making constructors payable saves gas on deployment.
Upon contract deployment, if the constructor is not payable, additional opcodes are generated to check if any ETH has been sent in the call, and revert if true. Having a payable constructor results in this check not being performed, thereby saving on deployment size and cost. Since the Escrow contract will be deployed many times, it is worth having this optimization.
After making the Escrow constructor payable, there was a gas saving of 15 gas on each test, and a total reduction of 405 gas across all tests. In addition, deployment size reduced by 6 bytes whereas deployment cost fell by 95 gas. This means a saving of ~100 gas on each Escrow deployment.
Gas
Forge, Foundry Toolkit (gas report, gas snapshots)
Make Escrow constructor payable.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.