The tokenURI function in the SoulboundProfileNFT contract includes a redundant explicit type cast of the age field (stored as uint8) to uint256 before converting it to a string. While functionally harmless, this redundancy adds unnecessary complexity and deviates from Solidity best practices for type handling.
Contract: SoulboundProfileNFT.sol
Function: tokenURI
The age field is stored as a uint8 in the Profile struct.
When converting age to a string, the code explicitly casts it to uint256 before calling Strings.toString():
Why This Is Redundant:
Solidity automatically converts smaller integer types (e.g., uint8) to uint256 during operations.
The Strings.toString() function accepts uint256 as input, making the explicit cast unnecessary.
No Functional Impact: The code operates correctly, and the cast does not affect the output.
Code Quality: Redundant operations reduce readability and may confuse developers during audits or maintenance.
Gas Efficiency: The explicit cast consumes a trivial amount of unnecessary gas (minor).
Remove the redundant cast by directly passing _profiles[tokenId].age to Strings.toString():
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.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.