Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

visibility of public functions can be changed to external, to save gas

Summary

In RamNFT.sol::mintRamNFT() and RamNFT.sol::updateCharacteristics() are marked with visibility as public which costs more gas when called by external contracts. Since, these functions are not being accessed internally, its advisable to change the visibility to external to save gas

Also RamNFT.sol::getCharacteristics view function is being used by ChoosingRam::increaseValuesOfParticipants() function so it need to be external. Do note that view functions cost gas when a contract makes a call to read its storage.

Also, there is a possibility that users might use smart contract wallets/external smart contracts to interact with the protocol. Using public functions will cost more gas than external visibility of function.

Impact

This will cost more gas to call these functions

Recommendations

Make sure to do below code changes in RamNFT.sol

code
- function updateCharacteristics(...) public
+ function updateCharacteristics(...) external
- function mintRamNFT(address to) public
+ function mintRamNFT(address to) external
- function setChoosingRamContract(address _choosingRamContract) public onlyOrganiser
+ function setChoosingRamContract(address _choosingRamContract) external onlyOrganiser
- function getCharacteristics(uint256 tokenId) public view returns (CharacteristicsOfRam memory)
+ function getCharacteristics(uint256 tokenId) external view returns (CharacteristicsOfRam memory)

Make sure to do below code changes in ChoosingRam.sol

code
- function selectRamIfNotSelected() public RamIsNotSelected OnlyOrganiser
+ function selectRamIfNotSelected() external RamIsNotSelected OnlyOrganiser
- function increaseValuesOfParticipants(...) public RamIsNotSelected
+ function increaseValuesOfParticipants(...) public RamIsNotSelected

Make sure to do below code changes in Dussehra.sol

code
- enterPeopleWhoLikeRam () public payable
+ enterPeopleWhoLikeRam () external payable
- function killRavana() public RamIsSelected
+ function killRavana() external RamIsSelected
- withdraw() public RamIsSelected OnlyRam RavanKilled
+ withdraw() external RamIsSelected OnlyRam RavanKilled

Updates

Lead Judging Commences

bube Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Info/Gas/Invalid according to docs

Support

FAQs

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