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

Unnecessary address(0) check in DecentralizedStableCoin.mint()

Summary

Unnecessary address(0) check in DecentralizedStableCoin.mint()

Vulnerability Details

The DecentralizedStableCoin.mint() function first checks if _to is not the 0 address and then calls the _mint() function of the ERC20 interface. The _mint() function of the ERC20 interface already implements address(0) check for the recipient so the check on L58 is not needed.Having such a check at the beginning of mint() will revert if address(0) is passed and gas won't be spent for the rest of the code.However if the function reverts due to the same check failing in _mint() then the gas used for the checks above will also be returned , so the check at L58 is redundant.The burn function is the same.

Impact

Gas optimization

Tools Used

Manual review

Recommendations

Remove the address(0) check on line 58 of DecentralizedStableCoin.sol

Support

FAQs

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