-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
About tokensOfOwner
function
#115
Comments
It seems like I have seen this debate between small cap/large cap a few times now. Thoughts on creating a "small cap" extension that could include multiple functions that might only be possible for these small cap collections? |
I have a question related to |
Nothing against Moralis, but if it could be done without adding a 3rd party why would you make it a requirement to get this information? Also |
@Austinhs you want to avoid O(totalSupply) methods which introduces DOS risks. IMO it's acceptable to add this to a contract situationnally if:
Otherwise it's quite straightforward to do this off-chain through contract logs, or (assuming a wallet has less than 10k transfer logs) even etherscan api |
Yeah I tend to agree with this like @Vectorized originally said this works well with majority of the low cap supplies <= 10,000 which 90% are. But a collection for example like crypto kiddies that have breeding and can easily hit 100k+ are the problem here. I think I will move this into a Also there is the option to just not add this -- but personally I've been doing some community service in twitter spaces to help newer dev's and ERC721A is a common topic. It would be hard for a newer dev to understand the architecture of ERC721A. Especially how to read the data, so I've actually been pointing them to this function to just explain how reading from ERC721A is a bit more complicated, I think adding a helper extension like |
Updated #114 to add this as a extension |
What we did is just remove ERC721Enumerable from our version of the ERC721A contract. In my opinion most projects just don't require this functionality and it's just not necessary to include it. The only function we keep from ERC721Enumerable is I'm having a hard time understanding why a project would need the extra ERC721Enumerable functions. Is it just so that they can easily enumerate an address' owned tokens so they can display them on their project website or some other frontend environment? Would love some clarification, appreciate your help! |
Yes, some of the market places might require NFT should use |
Enumerable is useful when implementing staking UI and getting all the tokens of a specific wallet. It is always good to have the contract as a source of truth and not 3rd party API. |
I agree with what is said above. On a ERC721 test project, I loop on balanceOf along with tokenOfOwnerByIndex to display on the frontend the nft minted by the connected address without using a third party service. In terms of user experience it seems to me to be a real plus. I'm interested if you have alternative solutions for that usecase. |
Hi, i have 10.000 items in my collection can i use this function? Is there any possiblity that this function crash my contract or my dapp? |
@justChargin 10k is safe. |
We added this, could we close this issue now? |
How can I call this function inside my contract? Why is it |
Our general advice is that you shouldn't be doing that. But if we will be more specific, please explain exactly what you're doing, and the sizes of all things involved. |
@sayhicoelho It is marked Calling it on-chain is highly not recommended, as it can cost millions of gas for typically sized collections. If you need to call it in your function (hopefully intended for off-chain queries), you can prefix it with a |
tokensOfOwner
function is definitely quite useful for small capped collections(probably > 90% of the collections you see these days).
However, we have to consider the implications of including a O(totalSupply) function in the main library. Even if we know if it supports collections of 10,000 unique items, it is still probable that someone will use this function for a collection of say 100,000 unique items, and result in off-chain queries from Infura (Metamask) / Alchemy failing.
Even if we include a cautionary comment, someone might just not read it and use the function without understanding the caveats.
One possible way to provide users convenience, but still keep the main library general is to include this in an examples folder, instead of an extension.
Let me know what you think.
@fulldecent @cygaar
Related:
The text was updated successfully, but these errors were encountered: