Retrieving all printed editions from a Solana master NFT

I need to fetch all printed editions that were created from a master NFT on Solana. The documentation mentions there’s a Program Derived Address (PDA) that connects editions back to their master, but I can’t figure out how to use this relationship with the Solana/Metaplex SDK.

Right now I’m using a workaround where I go through all transactions on the master NFT and look for edition creation events:

import {JsonMetadata, Metadata, Metaplex, TaskStatus} from "@metaplex-foundation/js";
import {Connection, PublicKey, ConfirmedSignatureInfo} from "@solana/web3.js";
import * as fs from "fs";

const ENDPOINT = 'https://...';
const MASTER_NFT_KEY = '';

(async () => {
    const conn = new Connection(ENDPOINT);
    const mx = new Metaplex(conn);

    const timestamp = new Date().toISOString()

    // Get all transaction signatures

    const txSignatures: { signature: string; }[] = []
    let beforeSig: string | undefined = undefined;
    while (true) {
        const results: ConfirmedSignatureInfo[] = await mx.connection.getSignaturesForAddress(
            new PublicKey(MASTER_NFT_KEY),
            {
                before: beforeSig
            },
            'finalized'
        )
        if (!results.length) break
        txSignatures.push(...results)
        beforeSig = results[results.length - 1].signature
    }

    // Check each transaction for edition creation

    const editionMints: string[] = []
    for (let j = 0; j < txSignatures.length; j++) {
        console.log(`${j}/${txSignatures.length}`);
        await mx.connection.getParsedTransaction(txSignatures[j].signature).then(transaction => {
            if (!transaction) return

            if (JSON.stringify(transaction).toLowerCase().includes('error')) return

            if (JSON.stringify(transaction).includes('Mint New Edition from Master Edition')) {
                console.log(JSON.stringify(transaction, null, 4))
                editionMints.push(transaction.transaction.message.accountKeys[1].pubkey.toString());
            }
        });
    }

    console.log('discovered:', editionMints.length, 'editions')
})()

This method gets really slow when there are lots of transactions. Is there a better way to do this?

Note: The first creator isn’t unique since it’s not from a Candy Machine, and the update authority might be shared across collections.

You can utilize Edition PDA seeds directly to retrieve all editions without having to parse through transactions. The Metaplex Token Metadata library generates edition accounts with easily predictable seeds: [“metadata”, token_metadata_program_id, master_mint, “edition”, edition_number]. However, since the edition numbers are not known in advance, using getProgramAccounts with appropriate filters is much more efficient. I’ve found that applying a filter based on the master edition’s mint address as the parent field in the edition data works effectively. Each edition account stores a reference to the master mint at a specific offset within its data. By leveraging getProgramAccounts along with a memcmp filter, you can quickly locate all accounts that reference your master mint. This method is significantly faster than parsing transaction histories, especially for high-volume collections. Just keep in mind that some RPC providers may impose limits on getProgramAccounts calls, so you might need a dedicated provider for extensive collections.

yeah, that’s rly inefficient tbh. you can use edition marker PDAs to find editions directly without parsing all those transactions. try findEditionMarkerPda from the Metaplex SDK and iterate through edition numbers - way faster than what ur doing now.

Interesting approach @Hugo_41Cook! I’ve been dealing with something similar. Quick question - have you hit any rate limiting issues with getProgramAccounts on larger collections?

Found another method that might work. Skip the transaction parsing and getProgramAccounts - try the digital asset standard (DAS) API if your RPC provider has it. The getAssetsByCreator or getAssetsByCollection endpoints are pretty efficient for this.

@BrilliantCoder39 - you said the first creator isn’t unique and update authority might be shared. Was this collection minted outside candy machine? That definitely makes things messier.

Might be worth checking out Helius or QuickNode APIs too. They’ve got NFT collection endpoints that could save you from parsing everything manually. Depends on your budget and if you’re cool with third-party services though.

What’s the collection size you’re working with? That’d help figure out the best approach.