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

Use assembly to check zero address

[G-04] Use assembly to check for the zero address

Number Of Instances: 2

https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/d1c5501aa79320ca0aeaa73f47f0dbc88c7b77e2/src/DecentralizedStableCoin.sol#L58C1-L60C10

if (_to == address(0)) {
revert DecentralizedStableCoin__NotZeroAddress();
}

https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/d1c5501aa79320ca0aeaa73f47f0dbc88c7b77e2/src/DSCEngine.sol#L103C9-L105C10

if (s_priceFeeds[token] == address(0)) {
DSCEngine__NotAllowedToken();
}

Recommendation

Using assembly for address comparisons in Solidity can save gas because it allows for more direct access to the Ethereum Virtual Machine (EVM), reducing the overhead of higher-level operations. Solidity's high-level abstraction simplifies coding but can introduce additional gas costs. Using assembly for simple operations like address comparisons can be more gas-efficient.

Support

FAQs

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