BAYC Otherside sales cost an unnecessary $100M in gas fees due to badly optimized code

Please fol­low and like us:
Pin Share

Syn­di­cate DAO co-founder Will Pap­per said on May 1 that inef­fi­cien­cies in the Yuga Labs Oth­er­side land sale caused $100 mil­lion to be need­less­ly wast­ed on gas fees.

In a Twit­ter thread, Pap­per explained how the smart con­tract used to mint the BAYC meta­verse land was miss­ing key opti­miza­tions. The smart con­tract fol­lows the ERC721 stan­dard, which Pap­per argued con­tains some func­tions and exten­sions that are “annoy­ing and unnecessary.”

To com­bat the inef­fi­cien­cies, he pro­posed three changes.

Remove the ERC721Enumerable extension

The first change Pap­per pro­posed is to remove the ERC721Enumerable exten­sion, which is used to track own­ers of NFTs on-chain.

Pap­per argued that there is no need to record own­ers on-chain since any­one can query the blockchain through an off-chain front end to pass the data into a smart con­tract. He said remov­ing the exten­sion alone could save 70% in gas fees by remov­ing a sin­gle word.

Use ERC721A… a standard developed by the Azuki

Pap­per said the ERC721A stan­dard devel­oped by the Azu­ki team is a bet­ter choice as it allows users to mint mul­ti­ple NFTs dur­ing the same trans­ac­tion for close to the cost of mint­ing just one.

He added that ERC721A makes mints “dra­mat­i­cal­ly cheap­er,” which off­sets the fact that it makes “trans­fers slight­ly more expensive.”

Based on Papper’s analy­sis, most users mint more than one NFT. He esti­mates this could have low­ered the over­all gas fees by $10 million.

Switch from _safeMint() to _mint()

The last opti­miza­tion that Pap­per rec­om­mend­ed is to replace the _safeMint() function.

He argued that this only helps ensure that a wal­let can accept NFTs and since most of the com­mu­ni­ty is like­ly using com­pat­i­ble and known wal­lets like Meta­mask, Trust­Wal­let, Coin­base Wal­let, and SafePal; this func­tion wastes gas fees.

Pap­per goes on to clar­i­fy that he is not attack­ing Yuga Labs for incom­pe­tence and acknowl­edged their con­tri­bu­tions to the indus­try. He said:

“[I have] spent count­less hours on gas opti­miza­tions and want­ed to share a few tricks. This thread is to edu­cate and doesn’t take away from the work that Yuga does for the ecosystem.”

He also shares a method­ol­o­gy that Syn­di­cateDAO uses for the mint­ing process to ensure that no one is try­ing to mint at the same time, thus dri­ving up gas fees.



Source link

Please fol­low and like us:
Pin Share

Leave a Reply

Your email address will not be published. Required fields are marked *