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

Redundant Use of `CharacteristicsOfRam` struct in `updateCharacteristics`

Summary

The updateCharacteristics function in the RamNFT contract uses a redundant struct assignment which increases gas costs. Optimizing this function can save gas and improve efficiency.

Vulnerability Details

The current implementation of the updateCharacteristics function creates a new instance of the CharacteristicsOfRam struct and reassigns it to the mapping. This redundancy can be optimized to save gas.

function updateCharacteristics(
uint256 tokenId,
bool _isJitaKrodhah,
bool _isDhyutimaan,
bool _isVidvaan,
bool _isAatmavan,
bool _isSatyavaakyah
) public onlyChoosingRamContract {
CharacteristicsOfRam storage characteristics = Characteristics[tokenId];
characteristics.isJitaKrodhah = _isJitaKrodhah;
characteristics.isDhyutimaan = _isDhyutimaan;
characteristics.isVidvaan = _isVidvaan;
characteristics.isAatmavan = _isAatmavan;
characteristics.isSatyavaakyah = _isSatyavaakyah;
}

Impact

Directly modifying the struct properties reduces gas costs by eliminating the need to create a new struct instance.

Tools Used

Manual code review.

Recommendations

Update the updateCharacteristics function to directly modify the struct's properties without creating a new instance.

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.