Yuga Labs has launched Sewer Pass NFT Collection for minting, which generated profits worth $6 million plus within a few hours.
The free Sewer Pass claim will be exclusively claimed on sites that value creator royalties. Now the question is, “Has Yuga Labs enhanced their smart contract skills?” Getting into details of Sewer Pass contracts and reviewing it will tell better.
Well, there are basically two contracts in terms of the Sewer Pass claim. Out of the two, one is the actual NFT contract, i.e. 0x764AeebcF425d56800eF2c84F2578689415a2DAa and the second one is the public minting contract.
For BAYC/MAYC, the cost to claim is ~180k gas units while for MAYC/BAYC + BAKC, it is ~220k gas units. Ideally, the optimized contract could have been something close to ~150k units.
To calculate the cost, it is important to know how the contract works. To do so, it is required to:
- Confirm whether the sender has a BAYC/MAYC.
- Confirm whether the sender has claimed their pass for the NFT.
- If yes, marking that the sender has claimed it.
- Calling the token contract to mint the pass.
In terms of the point #1, there’s not a lot to optimize.
For #1, there’s not too much to optimize. In YugaVerify.sol, the code gets the owner of the tokenId and checks if the msg.sender or the delegated address matches the token owner. A possible optimization is to only check 1 of https://t.co/1ZYIlGHeRg and https://t.co/mTxesjVHmT.— cygaar (@0xCygaar) January 18, 2023
The next two points are possible to optimize. The contract deploys a mapping (uint256 => bool) to track if a BAYC/MAYC token id has claimed a pass. It is not also possible to store the details but with savings as well by using a bitmap.
Since a bitmap utilizes pretty little storage space and uses warm reads/writes to decrease costs by almost 95%, Yuga Labs could have made great savings.
I did a whole thread on bitmaps vs mappings here: https://t.co/29NPlGVGpj, but the TLDR is a bitmap uses much less storage space and utilizes warm reads/writes to reduce costs by almost 95%. This is where Yuga could’ve obtained a chunk of savings.— cygaar (@0xCygaar) January 18, 2023
Coming to the last point, it would be wise to remove ERC721 Enumerable and only use a standard 721 implementation. Though this is personal but enumerable adds overhead costs and quite significant functionality can be read off-chain.
Other improvements include marking many lines unchecked, interchanging _safeMint with _mint, and removing the reentrancy guards on the claim functions.
To conclude, there’s no major improvement compared to the last time. However, the inclusion of http://delegate.cash and http://warm.xyz is praiseworthy since it enables users to mint from hot wallets.
More optimized contracts were possible if bitmaps were used and enumerability had been removed.