40,000 USDC
View results
Submission Details
Severity: gas

Constructors can be marked `payable`

Summary

Constructors can be marked payable

Vulnerability Details

Payable functions cost less gas to execute, since the compiler does not have to add extra checks to ensure that a payment wasn't provided. 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.

32 constructor(
33 uint256 price,
34 IERC20 tokenContract,
35 address buyer,
36 address seller,
37 address arbiter,
38 uint256 arbiterFee
39 ) {

https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L32-L39

Impact

Gas savings

Tools Used

Manual review

Recommendations

Mark constructor as payable

Support

FAQs

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