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

Improved Function Visibility in DecentralizedStableCoin.sol (burn())

Summary

This report is on the "DecentralizedStableCoin.sol" smart contract's burn function visibility, changing it from "public" to "external". The change was aimed at improving the contract's security by restricting the function's accessibility to external calls only. The report identified potential implications of this update.

Vulnerability Details

Improved Function Visibility:

The burn function's visibility to be updated from "public" to "external", limiting its execution to external calls only. In the previous "public" visibility, the contract owner could directly execute the burn function from within the contract.

Impact

The change in function visibility from "public" to "external" has a moderate impact on the contract's functionality and user interactions. By updating the burn function to "external", the contract owner can no longer directly execute the burn function from within the contract, which was previously allowed when the function was "public". The external visibility restricts the function's execution to be called only from external contracts or externally-owned accounts, disallowing direct execution from the contract's own functions.

Tools Used

Manual Code Review

Recommendations

To update the "burn" function's visibility to "external" from the current "public" setting, by making this change,

function burnDsc(uint256 _amount) external onlyOwner { // Changed the function name from "burn" to "burnDsc"
uint256 balance = balanceOf(msg.sender);
if (_amount <= 0) {
revert DecentralizedStableCoin__MustBeMoreThanZero();
}
if (balance < _amount) {
revert DecentralizedStableCoin__BurnAmountExceedsBalance();
}
burn(_amount);
}

Now, the function will only be accessible from external accounts and contracts.

Support

FAQs

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