1

So the tree is being created by the user on the client side (as they are gonna pay gas haha) but my application needs to allow one public key (that is my application's wallet) to mint compressed NFTs (that is make changes to the merkle tree).

How do I add a second tree delegate or authority or whatever when creating the tree/update this after creating the tree?

Currently this is the error I am getting with the bubblegum program (using metaplex's SDK)

Program Logs:
| Program BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY invoke [1]
| Program log: Instruction: MintToCollectionV1
| Program log: AnchorError thrown in src/lib.rs:1003. Error Code: TreeAuthorityIncorrect. Error Number: 6016. Error Message: Tree creator or tree delegate must sign..

Instruction for creating the tree -

 const createTreeIx = createCreateTreeInstruction(
    {
      payer: payerPublicKey,
      treeCreator: payerPublicKey,
      treeAuthority,
      merkleTree: treeKeypair.publicKey,
      compressionProgram: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID,
      // NOTE: this is used for some on chain logging
      logWrapper: SPL_NOOP_PROGRAM_ID,
    },
    {
      maxBufferSize: maxDepthSizePair.maxBufferSize,
      maxDepth: maxDepthSizePair.maxDepth,
      public: false,
    },
    BUBBLEGUM_PROGRAM_ID
  );

payerPublickey here is the user's public key (client side)

 const metaplex = Metaplex.make(connection).use(keypairIdentity(identity));

  const { response, nft } = await metaplex.nfts().create({
    name,
    uri,
    sellerFeeBasisPoints: 0,
    collection: collectionMint,
    collectionAuthority: identity,
    tree,
    tokenOwner: receiverAddress,
  });

identity here is the application wallet's keypair (server-side use).

I want identity to be able to mint compressed NFTs for the tree created by payerPublickey

1 Answer 1

1

Found out that the delegate cannot be set when creating the tree and additional delegates cannot be added but the delegate can be changed.

Used the createSetTreeDelegateInstruction function from @metaplex-foundation/mpl-bubblegum and it worked like a charm!

Example code:

 const [treeAuthority] = PublicKey.findProgramAddressSync(
    [treeKeypair.publicKey.toBuffer()],
    BUBBLEGUM_PROGRAM_ID
  );



const changeTreeDelegateIx = createSetTreeDelegateInstruction({
    merkleTree: treeKeypair.publicKey,
    newTreeDelegate: newDelegatePublicKey,
    treeAuthority,
    treeCreator: treeCreatorPublicKey,
  });

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.