Yuga Labs smart contracts not much improved

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:

  1. Confirm whether the sender has a BAYC/MAYC.
  2. Confirm whether the sender has claimed their pass for the NFT.
  3. If yes, marking that the sender has claimed it.
  4. Calling the token contract to mint the pass.

In terms of the point #1, there’s not a lot to optimize. 

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.  

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.