40,000 USDC
View results
Submission Details
Severity: gas
Valid

Gas optimisation

Summary

Vulnerability Details

Impact

Tools Used

Recommendations

  1. Use solidity version 0.8.20 or higher to save gas

https://github.com/Cyfrin/2023-07-escrow/blob/65a60eb0773803fa0be4ba72defaec7d8567bccc/src/EscrowFactory.sol#L2

  1. Mark the constructor as payable - Saves ~13 gas.
    https://github.com/Cyfrin/2023-07-escrow/blob/65a60eb0773803fa0be4ba72defaec7d8567bccc/src/Escrow.sol#L32C3-L39C8

  2. Functions guaranteed to revert when called by normal users can be marked payable

Mark functions with onlyBuyerorSeller or onlyarbiter as payable.

https://github.com/Cyfrin/2023-07-escrow/blob/65a60eb0773803fa0be4ba72defaec7d8567bccc/src/Escrow.sol#L94

https://github.com/Cyfrin/2023-07-escrow/blob/65a60eb0773803fa0be4ba72defaec7d8567bccc/src/Escrow.sol#L102

https://github.com/Cyfrin/2023-07-escrow/blob/65a60eb0773803fa0be4ba72defaec7d8567bccc/src/Escrow.sol#L109

  1. Use of && consumes more gas. Try separating the check without the use of &&.

https://github.com/Cyfrin/2023-07-escrow/blob/65a60eb0773803fa0be4ba72defaec7d8567bccc/src/Escrow.sol#L67

Non-critical issues

  1. "chosing" should be changed to "choosing"
    https://github.com/Cyfrin/2023-07-escrow/blob/65a60eb0773803fa0be4ba72defaec7d8567bccc/src/EscrowFactory.sol#L19C57-L19C57

Support

FAQs

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