5
  1. I would like to do the following on the front-end. I would like to have a list of "collections" we support and which user can select from. User connects to Phantom wallet and selects "collection A". Now I check all tokens in the user's wallet that belong to the "collection A" selected by the user. I was reading this thread https://forums.solana.com/t/possible-to-query-all-nft-addresses-in-a-specific-collection/3097/7 which basically says there is no easy way to query spl-tokens that belong to a specific collection because on solana there are no such things as collections.

How do you handle then releasing 1000 different (nft) tokens that are supposed to be under the same theme? They are collections in the end right? Also there was apparently a tool for it but the docs have been removed: what happened with https://docs.metaplex.com/mint-lists

Reading https://docs.metaplex.com/programs/token-metadata/ I learned that Metaplex attaches metadata to PDA of Mint Account. Could we maybe us that to identify a collection, if tokens have been release by Metaplex products

Thanks for your suggestions!

EDIT:

Apparently there is a solution for it already and collections are supported for months. ENTER: https://github.com/metaplex-foundation/js

This skd should support all nft related needs. Will test it and let others know if I managed to accomplish the task.

UPDATE 28.07.2022.

I had a look at the metaplex SDK and I can see that you have a method

metaplex.nfts().findByMint(mint).run();

Which is cool. So the part of getting the metadata could work.

However, the second part of the answer from @Mark Sackerberg:

and then filter by collection key in their metadata.

could be problematic.

Hey @Mark Sackerberg, I have deployed a test collection using metaplex on devnet.

  1. Mint address https://www.solaneyes.com/address/3fpk4L7tiEAbyqcuTVgTnhcpQ5PuG4rX6HXRRZu1gHhj
  2. Token address https://www.solaneyes.com/address/8nKu16RmMRM2ivEgKBtRBNsrBUsauckQ7Zb5JFUAdb6Z
  3. Metadata address https://www.solaneyes.com/address/ritvGTaMVdhhLTGBYeHw4LKoVrVNedmNTqmRWd6hct1

How can I now find all NFTs in the user's wallet that belong to this collection?

EDIT 29.08:

I found an answer.

If a collection has been deployed via metaplex AND it has attached collection metadata json config you can then query all NFTs that a user owns by doing:

const userNfts: (Nft | LazyNft)[] = await mx.nfts().findAllByOwner(userPublicKey).run()

Each nft that belongs to a collection, will have a collection property which is an object containing:

  1. Verified. More on the subject here
  2. Key (the mint address of the collection. You can treat it as CollectionId)

Then you need to filer those nfts based on that property using your language.

3
  • It is better to keep questions focused by only asking one per post. Please move #2 to it's own post, assuming an existing question doesn't already cover it
    – trent.sol
    Commented Jul 21, 2022 at 18:31
  • Not really in this case @trent.sol. The question is how to filter collections. The questions are following the same thread of thought and are not separate questions on different subjects. It should stay under this question so that people who are having the same questions are finding the answer here. Thanks
    – Digital
    Commented Jul 28, 2022 at 11:59
  • i disagree. the former is a novel question AFAIK, whereas the latter has been asked and answered many times here in various forms
    – trent.sol
    Commented Jul 28, 2022 at 17:43

1 Answer 1

3

The content of the solana forums link is outdated. Metaplex Token metadata Standard supports collections for months now.

You can for example use the metaplex js sdk to get all nfts the connected wallet owns and then filter by collection key in their metadata.

The metaplex js sdk should provide all solana related things you need

2
  • Hey Mark, could you have a look at last update to my answer.
    – Digital
    Commented Jul 28, 2022 at 11:26
  • can you please describe what you changed? Commented Jul 28, 2022 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.