js-deprecated
js-deprecated copied to clipboard
find many NFTs by their symbol
Is your feature request related to a problem? Please describe. I need to retrieve the NFT's in a collection. I think that I can do this using the symbol.
Here is what I unsuccesfuly tried:
const symbol = "POP"
const symbolBytes = bs58.encode(Buffer.from(symbol))
const nfts = await programs.metadata.MetadataProgram.getProgramAccounts(
connection,
{
filters: [
{
memcmp: {
offset:
1 + // key
32 + // update auth
32 + // mint
4 + // name string length
32 + // name
4 + // uri string length
200 + // uri
4, // symbol string length
bytes: symbolBytes,
},
},
],
}
)
It returns an empty list.
Describe the solution you'd like Maybe we could enhance the findMany method to use the search by symbol. I could contribute with a PR if I understand what my above issue is.
Describe alternatives you've considered I did not found any other idea about how I can accomplish this task at the moment. Maybe there is a better idea ?
Additional context I am building a NFT marketplace, that's why I need to retrieve a list of NFTs by collection.
At the moment, I managed to target the main creator using findMany
from the Metadata program. It works but I fear that it might be imprecise on some collections.
Can you show how you did that? I'm getting fetch errors when I try it that way.