kadenzipfel / gas-optimizations

List of smart contract optimizations in solidity
610 stars 61 forks source link

Payable constructor #2

Open pcaversaccio opened 2 years ago

pcaversaccio commented 2 years ago

The payable modifier can also help to reduce deployment costs. You can cut out 10 opcodes in the creation-time EVM bytecode if you declare a constructor payable. The following opcodes are cut out:

In Solidity, this chunk of assembly would mean the following:

if(msg.value != 0) revert();

I've compiled further gas optimisation tricks here.

pcaversaccio commented 1 year ago

Is it planned to add this optimisation? Otherwise, feel free to close the issue.