Closed GrimLothar closed 2 years ago
Hi there 👋
Yes, that's because when fetching multiple NFTs from the blockchain, it isn't performant to fetch additional accounts, such as the token account, as well.
Instead, it simply returns the Metadata model which can transformed into a NftWithToken using the nfts().load()
operation. This is explained in the readme.
Hey @lorisleiva thank you for your reply!
I'm probably making wrong assumptions here, but running nfts().load()
on hundreds of individual accounts sounds less performant than running the native web3 method getParsedTokenAccountsByOwner
. (100s calls vs 1).
It depends on the information you're looking for. The idea with this operation is that you lazy load the metadata accounts and then load the full data (including fetching its JSON metadata) as and when you need it. It would not be performant to load the URIs and Token accounts of all of them in one go (especially has we don't control where the URIs point from).
A good example for using this operation is displaying NFTs in a web page. For instance, you may want to paginate that list and display more information on the NFT whenever the user clicks on it.
Now, if you're mostly interested in the token accounts to find out about delegate authorities then that operation is less useful to you and using the RPC method you mentioned should be more performant.
Something the SDK could support in the future is a similar operation on the Token module so you could do something like metaplex.tokens().findAllByOwner()
and that would return a list of Token
instead of metadata.
I hope this helps.
Awesome, thank you for taking the time to confirm which route to take (for now, until the SDK supports that other method that sounds amazing)
Thanks!
I noticed that while all the
findBy
methods include an output ofNftWithToken
, thefindAllBy
don'tI also noticed that the
delegateAddress
is only available in theToken
model.So that's basically not allowing me to check if the NFTs being returned by
findAllByOwner
have adelegateAddress
or not.Is there something I'm missing to be able to check the
delegateAddress
when when usingfindAllBy
methods?Thank you!