DatingDapp

First Flight #33
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

Emitting Dynamic Strings in Events

Summary

Emitting dynamic strings in an event increases gas costs significantly because:

  • Strings are not indexed in event logs, making them inefficient for search and filtering.

  • Events are meant for lightweight logging, but logging large strings (especially profileImage, which might be a long URL or metadata) is expensive.

  • Alternative approaches (such as using bytes32 for hashes or storing data off-chain) can reduce costs.

Impact

High gas costs due to unnecessary storage of dynamic strings in an event.

  • Inefficient event indexing because strings cannot be indexed, making on-chain queries expensive.

Tools Used

manual review

Recommendations

Store profileImage as a bytes32 Hash Instead

Before emitting, hash the profileImage string

event ProfileMinted(address indexed user, uint256 tokenId, string name, uint8 age, bytes32 profileImageHash);
Updates

Appeal created

n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Support

FAQs

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