Platform: Code4rena
Start Date: 23/11/2022
Pot Size: $24,500 CANTO
Total HM: 5
Participants: 37
Period: 5 days
Judge: berndartmueller
Total Solo HM: 2
Id: 185
League: ETH
Rank: 26/37
Findings: 1
Award: $13.69
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Tricko
Also found by: 0xhacksmithh, AkshaySrivastav, Awesome, Beepidibop, Deivitto, DijkstraDev, Dinesh11G, Englave, JC, Rahoz, RaymondFam, ReyAdmirado, SaeedAlipoor01988, Sathish9098, abiih, aphak5010, chaduke, chrisdior4, exolorkistis, gzeon, martin, nicobevi, oyc_109, peritoflores, rotcivegaf
84.7394 CANTO - $13.69
withdraw
function, due to Line 135 _amount
value can never exceed earnedFees
, the Line 137 can be put inside an unchecked
block.135 if (_amount > earnedFees) _amount = earnedFees; 137 137 balances[_tokenId] = earnedFees - _amount;
msg.sender
value is stored in an address
variable in memory. This value is then read and used at multiple places. It is recommended to use msg.sender
directly without storing/reading from memory to save gas.function register(address _recipient) public onlyUnregistered returns (uint256 tokenId) { address smartContract = msg.sender; // code clipped... emit Register(smartContract, _recipient, tokenId); feeRecipient[smartContract] = NftData({ tokenId: tokenId, registered: true }); }
It is recommended to simply use a uint256
variable instead if Counters
library to save gas.
<x> += <y> costs more gas than <x> = <x> + <y> for state variables.
balances[_tokenId] += msg.value;
#0 - c4-judge
2022-11-29T19:16:00Z
berndartmueller marked the issue as grade-b