3

I've been able to successfully create individual NFTs using Solana and Anchor, but I'm struggling to find the right approach for creating NFT collections dynamically on-chain. When creating a single NFT, I understand that I can use the #[account] attribute to initialize a "Mint" account for the NFT. However, I want to empower users to create multiple NFTs associated with a single collection, or simply enable them to create more than one NFT.

Ideally, I would like to do this on-chain to ensure a seamless user experience. As each NFT may have its own metadata, they might share the same owner and authority accounts. However, I'm facing challenges in creating multiple dynamic "Mint" accounts within the on-chain function due to lifetime, borrowing, and temporary value errors.

Could anyone provide guidance on the correct approach for creating NFT collections on-chain using Anchor and Rust? How can I allow users to create one or more NFTs associated with a collection, while ensuring that they share the same "Mint" account and have consistent metadata? If you have any code examples, ideas, or repositories that demonstrate this process, I would greatly appreciate your assistance. I've been trying for several days and would really value some insights into how to implement this effectively.

Thank you for your time and help!

2 Answers 2

2

Candy Machine is a program that allows for the creation of NFT drops, what it does is create the configuration for NFTs and then users can mint the one by one, with all NFTs belonging to the same collection.

Check the initialize_v2 and mint_v2 instructions on how they handle minting.

https://github.com/metaplex-foundation/mpl-candy-machine/tree/main/programs/candy-machine-core/program/src/instructions

1
  • I see the CM code but initially I see it as very long and complex to understand, I still don't understand how to dynamically create the new mint addresses. Or is it not possible? What I can see in the CM code is that using the instructions created by CM creates a CM similar to what can be done with JS. But in this case I don't necessarily need to create a CM. I can't find examples applied to reality, looking at all the possible instructions doesn't help me much, but still Thank you very much, if you have any examples that would be great. Aug 3, 2023 at 12:24
1

You can do this using an Anchor program with two instructions.

  • First mint a "collection" nft
  • Then mint nfts as part of the "collection"

Note that if you do this through an Anchor program you'll need to set higher compute units for the transaction when invoking the instructions due to all the CPIs required.

Here is an example you can reference where a PDA is used for the "collection" nft and the update authority of the nft. Then when creating an nft in the collection, the PDA can sign to verify the new nft as part of the collection using set_and_verify_sized_collection_item.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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