Platform: Code4rena
Start Date: 29/06/2022
Pot Size: $50,000 USDC
Total HM: 20
Participants: 133
Period: 5 days
Judge: hickuphh3
Total Solo HM: 1
Id: 142
League: ETH
Rank: 73/133
Findings: 2
Award: $68.31
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: xiaoming90
Also found by: 0x1f8b, 0x29A, 0x52, 0xDjango, 0xNazgul, 0xNineDec, 0xSolus, 0xf15ers, 0xsanson, AmitN, Bnke0x0, BowTiedWardens, Chom, David_, ElKu, Funen, GalloDaSballo, GimelSec, Hawkeye, IllIllI, JC, JohnSmith, Kaiziron, Kenshin, Lambda, Limbooo, MadWookie, Metatron, MiloTruck, Nethermind, Picodes, ReyAdmirado, Sneakyninja0129, StErMi, TomJ, Treasure-Seeker, TrungOre, Waze, Yiko, _Adam, __141345__, antonttc, async, aysha, catchup, cccz, cryptphi, csanuragjain, danb, datapunk, defsec, delfin454000, dirk_y, doddle0x, durianSausage, exd0tpy, fatherOfBlocks, gogo, hake, hansfriese, horsefacts, hubble, itsmeSTYJ, joestakey, oyc_109, pedroais, peritoflores, rajatbeladiya, reassor, robee, rokinot, samruna, saneryee, sashik_eth, shenwilly, shung, simon135, sseefried, unforgiven, zer0dot, zzzitron
47.1318 USDC - $47.13
#1 Immutable Impact the baseURI can't be initialize by constructor.
Proof of Concept https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L132 https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L137
Tool Used Remix
Recommendation Mitigation steps the state must add immutable because in the constructor parameter mention state to initialize. so i suggest to add immutable on baseURI.
#2 Remove payable Impact useless payable caused the function not use to receive a token.
Proof of Concept https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L228 https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L240
Tool Used remix
Recommendation Mitigation Steps Remove payableon the function().
#3 Use Call instead transfer Impact usage of send() or transfer() would cause an out of gas error.
Proof Of Concept https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L336
Tool Used Manual Review
Recommended Mitigation Steps use .call() because .transfer() fowards 2300 gas whereas .call() forwards all / set gas..
#4 Use safetransfer Impact safeTransfer returns boolean, which is much safer than transfer.
Proof of concept https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L368-L367
Tool Used Remix
Recommendation Mitigation Steps Use safetransfer for safer in transfer token erc721
#5 Use safetransferForm Impact used to safely transfer the NFT from the owner's account to the recipient account.
Proof of concept https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L413
Tool Used Remix
Recommendation Mitigation Steps Use safeTransferForm instead TransferForm for safely transfer in NFT.
#6 Typo separator (seperator) Impact decrease readibility
Proof of concept https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L751
Tool Used Manual Review
Recommendation Mitigation Steps change word seperator to separator.
🌟 Selected for report: GalloDaSballo
Also found by: 0v3rf10w, 0x1f8b, 0xA5DF, 0xDjango, 0xHarry, 0xKitsune, 0xNazgul, 0xNineDec, 0xc0ffEE, 0xf15ers, 0xkatana, 0xsanson, ACai, Aymen0909, Bnke0x0, BowTiedWardens, Chom, ElKu, Fitraldys, Funen, Haruxe, Hawkeye, IllIllI, JC, JohnSmith, Kaiziron, Kenshin, Lambda, Limbooo, MadWookie, Metatron, MiloTruck, Picodes, PwnedNoMore, Randyyy, RedOneN, ReyAdmirado, Ruhum, Sm4rty, StErMi, StyxRave, TerrierLover, TomJ, Tomio, UnusualTurtle, Waze, Yiko, _Adam, __141345__, ajtra, ak1, apostle0x01, asutorufos, c3phas, cRat1st0s, catchup, codetilda, cryptphi, datapunk, defsec, delfin454000, durianSausage, exd0tpy, fatherOfBlocks, gogo, grrwahrr, hake, hansfriese, horsefacts, ignacio, jayfromthe13th, joestakey, ladboy233, m_Rassska, mektigboy, minhquanym, mrpathfindr, natzuu, oyc_109, rajatbeladiya, reassor, rfa, robee, rokinot, sach1r0, saian, sashik_eth, simon135, slywaters, swit, z3s, zeesaw, zer0dot
21.1794 USDC - $21.18
#1 Visibility
change visibility from public to private or internal can save gas. so i recommend to change it.
#2 use calldata instead memory
the function() has an inputed parameter that using memory, if this function didnt change the parameter, its cheaper to use calldata then memory. so we suggest to change it.
#3 use !=0 insted of >0
for unsigned integer, >0 is less efficient then !=0, so use !=0 instead of >0. apply to others.
#4 Cache the floorAssetTokenIds.length
caching floorAssetTokenIds.length to memory because use multiple times can reduce the gas.
#5 Default value uint
the default value of uint is 0, so remove unnecassary explicit code initializations for default values e.g uint i = 0; to uint i;.
#6 Looping (aritmathic)
default uint is 0 so remove unnecassary explicit can reduce gas. caching the array length can reduce gas it caused access to a local variable is more cheap than query storage / calldata / memory in solidity. pre increment e.g ++i more cheaper gas than post increment e.g i++. i suggest to use pre increment.
#7 Cache orders.length
caching orders.length to memory because use multiple times can reduce the gas.
#8 Cache signatures.length
cache the signatures.length to memory because use multiple times can reduce the gas.
#9 use storage instead memory https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L582
Use storage instead of memory to reduce the gas fee. i suggest to change memory with storage.