1
votes

Is there any way to filter a users wallet by candy machine id? I know how to get all of a users nfts via getParsedTokenAccountsByOwner.

 const tokens = await connection.getParsedTokenAccountsByOwner(publicKey, {
   mint: mintAccount,
   programId,
 });

 const nftList = tokens.value.filter((row) => {
   return row.account.data.parsed.info.tokenAmount.amount === "1";
 });

The problem, I'd have to get the metadata for each token and then filter it from there, which is a lot of unneeded hits to the the chain. I know I can get all the addresses for a candy machine via getProgramAccounts but this is slow, and can take about 30 seconds to run.

This def makes a front end display of a specific candy machine tokens frustrating with out any sort of caching layer + regular polling which I'm trying to avoid if possible.