I need help getting all printed editions that were created from a master NFT on Solana. The documentation mentions there’s a Program Derived Address that connects each edition back to its master, but I can’t figure out how to find this connection using the Solana/Metaplex SDK.
Right now I’m using a workaround where I fetch all transactions from the master NFT and look for edition creation events:
import {Metadata, Metaplex} from "@metaplex-foundation/js";
import {Connection, PublicKey} from "@solana/web3.js";
const RPC_ENDPOINT = 'https://...';
const PARENT_NFT_ADDRESS = '';
(async () => {
const conn = new Connection(RPC_ENDPOINT);
const mplex = new Metaplex(conn);
// Get all transaction signatures
const txSignatures = [];
let lastSignature = undefined;
while (true) {
const results = await mplex.connection.getSignaturesForAddress(
new PublicKey(PARENT_NFT_ADDRESS),
{ before: lastSignature },
'confirmed'
);
if (!results.length) break;
txSignatures.push(...results);
lastSignature = results[results.length - 1].signature;
}
// Check each transaction for edition creation
const editionMints = [];
for (let idx = 0; idx < txSignatures.length; idx++) {
const parsedTx = await mplex.connection.getParsedTransaction(txSignatures[idx].signature);
if (parsedTx && JSON.stringify(parsedTx).includes('Mint New Edition from Master Edition')) {
editionMints.push(parsedTx.transaction.message.accountKeys[1].pubkey.toString());
}
}
console.log('Total editions found:', editionMints.length);
})();
This approach gets really slow when there are lots of transactions to process. Is there a better way to do this?
Note: I can’t use the first creator or update authority to filter since they’re shared across multiple collections.