Open R-qanawati opened 2 years ago
Gas usage for users: 95,970 Gas usage for deployer: 973,534
@R-qanawati
How many tokens does the deployer wallet hold? If the deployer wallet minted a relatively large amount of tokens, upon calling safeTransferFrom
, the ownerOf
lookup may be quite expensive assuming I understand your issue correctly.
Minted about 350 total
Minted about 350 total
if you didn't create any "bundle" mechanism (forcing ownership to actually be written every X items minted) this is totally normal to have that kind of costs.
When transfering item 349, the contract will have to do a lookup that goes through all items until the first minted (so reading 349, 348, 347, 346, ... 3, 2, 1) in order to find the ownership.
This is the biggest downside to ERC721A, the "algorithm" for finding the owner of a given token searches linearly backward until if finds the owner. This makes it highly inefficient for "selling" tokens on something like OpenSea where someone can purchase any item in the collection. We ended up transferring every 50th token to normalize the gas cost for selling tokens across the whole collection.
What this really needs is a more efficient algorithm for determining the ownership of a given token, probably at the expense of more storage and higher upfront cost I would guess.
Sorry for the noob question but curious why the deployer wallet is paying about 40$ gas fee vs everyone else paying a 5$ gas fee to make a safeTransfer.
Is there any solution to it?