Platform: Code4rena
Start Date: 03/05/2022
Pot Size: $30,000 USDC
Total HM: 6
Participants: 93
Period: 3 days
Judge: gzeon
Id: 118
League: ETH
Rank: 80/93
Findings: 1
Award: $15.71
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: BowTiedWardens
Also found by: 0v3rf10w, 0x1f8b, 0x4non, 0xDjango, 0xNazgul, 0xProf, 0xc0ffEE, 0xf15ers, 0xkatana, 0xliumin, ACai, AlleyCat, CertoraInc, Cityscape, Cr4ckM3, DavidGialdi, Dinddle, FSchmoede, Funen, GimelSec, Hawkeye, IllIllI, Kulk0, M0ndoHEHE, MaratCerby, MiloTruck, Picodes, RoiEvenHaim, Tadashi, TerrierLover, TrungOre, VAD37, WatchPug, antonttc, catchup, defsec, delfin454000, dirk_y, eccentricexit, ellahi, fatherOfBlocks, gzeon, hake, hansfriese, hickuphh3, horsefacts, ilan, joestakey, kebabsec, kenta, kenzo, marximimus, minhquanym, noobie, oyc_109, p4st13r4, pauliax, rajatbeladiya, reassor, rfa, robee, rotcivegaf, saian, samruna, shenwilly, shung, simon135, slywaters, sorrynotsorry, throttle, unforgiven, z3s
15.7086 USDC - $15.71
Revert strings greater than 32 bytes will consume more gas during deployment and when the require condition is met
reduce the string size to 32 bytes
When there is no implementation of meta-transactions, msg.sender can be used directly
replace _msgSender() with msg.sender
ForgottenRunesWarriorsGuild#forwardERC20s
require condition will always be true as msg.sender will not be address(0)
function forwardERC20s(IERC20 token, uint256 amount) public onlyOwner { require(address(msg.sender) != address(0));
require statement can be removed
Storage variables that are re-read can be stored in a temporary variables and re-used instead of re-reading to save gas
tokenId
can be used in the first require statement instead of reading from storage
require(numMinted < MAX_WARRIORS, 'All warriors have been summoned'); require(_msgSender() == minter, 'Not a minter'); uint256 tokenId = numMinted;
numSold
, maxDaSupply
in
numSold
, maxForSale
in
startPrice
, lowestPrice
, daStartTime
,lowestPrice
weth
in
Storage variable can be stored in a temporary variable and re-used
i++
can be replaced with ++i
As return value of ++i
is not used, it can be replaced with ++i
to save gas, and unchecked can be added as there is no chance of overflow due to the condition
post-increment can be replaced with pre-increment
Adding unchecked to statements that cant overflow/underflow can avoid the default overflow/underflow checks introduced in v0.8 and save gas
if (stepDeduction > startPrice) { return lowestPrice; } uint256 currentPrice = startPrice - stepDeduction;
Add unchecked to the statement