15,000 USDC
View results
Submission Details
Severity: gas

[G-02] Setting the `constructor` to `payable`

Summary

Setting the constructor to payable can save gas during contract deployment by avoiding unnecessary opcodes.

Proof Of Concept

  • https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/main/src/DecentralizedStableCoin.sol#L44

constructor() ERC20("DecentralizedStableCoin", "DSC") {}
  • https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/main/src/DSCEngine.sol#L112

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

Gas saved ~ 13 gas per instance

Support

FAQs

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