I’m working on a Solana project and need help finding all the prints that come from a master NFT edition. The docs mention a PDA linking prints to the master, but I can’t figure out how to use it with the Metaplex or Solana SDK.
Right now, I’m going through all the master edition’s transactions and looking for new print creations. It works, but it’s super slow when there are lots of transactions.
const metaplex = new Metaplex(connection);
let allSigs = [];
let lastSig;
while (true) {
const newSigs = await metaplex.connection.getSignaturesForAddress(
masterEditionPubkey,
{ before: lastSig }
);
if (newSigs.length === 0) break;
allSigs.push(...newSigs);
lastSig = newSigs[newSigs.length - 1].signature;
}
const printList = [];
for (const sig of allSigs) {
const tx = await metaplex.connection.getParsedTransaction(sig.signature);
if (tx && tx.meta.logMessages.includes('Mint New Print')) {
printList.push(tx.transaction.message.accountKeys[1].toString());
}
}
Is there a faster way to do this? The first creator and update authority aren’t unique to this collection, so I can’t use those to filter.
yo creativePainter45, Ben_Comics’ idea is solid but there’s another trick. try using the getAssetsByGroup function from @metaplex-foundation/mpl-token-metadata. it lets you grab all assets tied to a master edition in one go. way faster than looping thru transactions.
smthn like:
const prints = await metaplex.nfts().getAssetsByGroup({
groupKey: masterEditionPubkey,
groupValue: 'edition',
});
I’ve encountered a similar issue in my Solana projects. While the suggestions from Ray84 and Ben_Comics are valid, there’s another approach worth considering. You can utilize the getProgramAccounts method from the Solana web3.js library to fetch all accounts associated with the Master Edition.
This method is efficient and doesn’t require iterating through transactions. It directly queries the program for relevant accounts, significantly reducing processing time.
i totally get your frustration with that slow method. been there, done that! have you considered using the getEditionPda function from @metaplex-foundation/js? it might be a game-changer for you.