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

Use hardcode address instead address(this)

Summary

[G-20] Use hardcode address instead address(this)

Instead of using address(this), it is more gas-efficient to pre-calculate and use the hardcoded address. Foundry’s script.sol and solmate’s LibRlp.sol contracts can help achieve this.
References: https://book.getfoundry.sh/reference/forge-std/compute-create-address

file: /src/DSCEngine.sol
157 bool success = IERC20(tokenCollateralAddress).transferFrom(msg.sender, address(this), amountCollateral);

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

Support

FAQs

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