Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payable constructor #2

Open
pcaversaccio opened this issue Jul 3, 2022 · 1 comment
Open

Payable constructor #2

pcaversaccio opened this issue Jul 3, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@pcaversaccio
Copy link

pcaversaccio commented Jul 3, 2022

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:

  • CALLVALUE
  • DUP1
  • ISZERO
  • PUSH2
  • JUMPI
  • PUSH1
  • DUP1
  • REVERT
  • JUMPDEST
  • POP

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

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

I've compiled further gas optimisation tricks here.

@kadenzipfel kadenzipfel added the enhancement New feature or request label Jul 3, 2022
@pcaversaccio
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants