Platform: Code4rena
Start Date: 17/03/2023
Pot Size: $36,500 USDC
Total HM: 10
Participants: 98
Period: 3 days
Judge: leastwood
Total Solo HM: 5
Id: 223
League: ETH
Rank: 96/98
Findings: 1
Award: $12.03
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xSmartContract
Also found by: 0xdaydream, 0xnev, Aymen0909, Deekshith99, Diana, EvanW, Fanz, JCN, Jerry0x, K42, Kresh, Madalad, MiniGlome, Polaris_tow, Rageur, ReyAdmirado, Rolezn, SAAJ, SaeedAlipoor01988, Sathish9098, Shubham, Udsen, Viktor_Cortess, Walter, anodaram, arialblack14, atharvasama, caspersolangii, codeslide, descharre, fatherOfBlocks, felipe, ginlee, igingu, lukris02, nadin, slvDev, tnevler, turvy_fuzz, viking71
12.034 USDC - $12.03
The protocol ProfilePicture.sol
has the state variable subprotocolName
in line number 35. which is a string data type. This result in excessive gas usage when the variable is accessed repeatedly since string variables are expensive to store and manipulate.
contract ProfilePicture is ERC721 { string public subprotocolName; constructor(address _cidNFT, string memory _subprotocolName) ERC721("Profile Picture", "PFP") { cidNFT = ICidNFT(_cidNFT); subprotocolName = _subprotocolName; } function tokenURI(uint256 _id) public view override returns (string memory) { }}
the subprotocolName
variable should be changed from a string
data type to a bytes32
data type. This will reduce the gas costs of accessing the variable since bytes32
variables are cheaper to store and manipulate. as shown below code snippet.
contract ProfilePicture is ERC721 { byte32 public subprotocolName; constructor(address _cidNFT, string memory _subprotocolName) ERC721("Profile Picture", "PFP") { cidNFT = ICidNFT(_cidNFT); subprotocolName = _subprotocolName; _registerInterface(bytes4(keccak256('tokenURI(uint256)'))); } function tokenURI(uint256 _id) public view override returns (string memory) { }}
#0 - c4-judge
2023-04-11T04:26:54Z
0xleastwood marked the issue as grade-b