1

I'm working on an NFT project and while I can easily mint an NFT with the Metaplex Token Metadata program (an individual or a collection NFT) I'm struggling somewhat with how to correctly call set_and_verify_collection, in order to verify that the NFT being minted is verified as being part of the collection.

I've been spinning my wheels for the past few days and I suspect that there's something fundamental that I'm missing with how to use this (and/or my understanding of the different accounts/keys required).

My mint function can be found here and as you can see it's similar to numerous examples found online (with a few tweaks). The payer/update authority is my own wallet (again, am trying to keep this as simple as possible in order to get it working). The mint function is passed the pubkey of the collection NFT, too.

Does anyone have a concrete example of how set_and_verify_collection ought to be invoked?

Thanks!

1

1 Answer 1

1

I checked your code and it seams like you are setting the payer as the UA(Update Authority) while creating the metadata account. To Correctly Invoke set_and_verify_collection a Collection NFT needs to be created before hand and important thing to note regarding set_and_verify_collection is that it requires the UA of the collection NFT to be the Signer.

I can think of a way according to your current code base you shared. Since you have assigned payer as the UA initially you have to update that to the UA address of the Collection NFT. The update can be done using update_metadata_accounts_v2 once both the NFTs have the same UA. A decision needs to be made that to keep the UA as a PDA or a normal address. If it's a PDA invoking set_and_verify_collection is going to be easier. If it's a normal address then you need to create a server through which you have to channel each and every tx and sign it by the UA. i would prefer the PDA solution as it's secure and better.

After All this long explanation let's see how's does it get's invoked

 invoke_signed(
    set_and_verify_collection(
        *ctx.accounts.mpl_program.key,
        ctx.accounts.metadata.key(),
        ctx.accounts.pda.key(),
        ctx.accounts.payer.key(),
        ctx.accounts.pda.key(),
        ctx.accounts.collection_mint.key(),
        ctx.accounts.collection_metadata.key(),
        ctx.accounts.collection_masteredition.key()
    ),
    &[
        ctx.accounts.metadata,
        ctx.accounts.pda,
        ctx.accounts.payer,
        ctx.accounts.pda,
        ctx.accounts.collection_mint,
        ctx.accounts.collection_metadata,
        ctx.accounts.collection_masteredition
    ],
    &[update_authority_pda_signer]
)?;

the update_authority_pda_signer in the above code refers to the PDA.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.