15,000 USDC
View results
Submission Details
Severity: gas

Constructors can be marked `payable`

Summary

Payable functions cost less gas to execute

Vulnerability Details

Since the compiler does not have to add extra checks to ensure that a payment wasn't provided, payable functions cost less gas. A constructor can safely be marked as payable, since only the deployer would be able to pass funds, and the project itself would not pass any funds.

112 constructor(address[] memory tokenAddresses, address[] memory priceFeedAddresses, address dscAddress) {

https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/main/src/DSCEngine.sol#L112

Impact

Save 21 gas

Tools Used

Manual review

Recommendations

Set constructor as payable

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!