5

I am trying to approve delegation of multiple NFTs without having multiple transactions. Is this possible with the metaplex js library? Here is the code:

await this.metaplex.tokens().approveDelegateAuthority({
  mintAddress: nftMint,
  //@ts-ignore
  delegateAuthority: this.publicKey,
});

I am looking for a way to have something like this:

const delegatenft1 = this.metaplex.tokens().approveDelegateAuthority({
  mintAddress: nftMint,
  //@ts-ignore
  delegateAuthority: this.publicKey,
});

const transaction = new Transaction().add(delegatenft1, delegatenft2, delegatenft3, ...)

1 Answer 1

3

You can use builders in metaplex js library to get transaction builder and then convert it into transaction

const latestBlockhash = await   
 this.metaplex.connection.getLatestBlockhash();

const delegatenft1 = this.metaplex.tokens().builders().approveDelegateAuthority({
  mintAddress: nftMint2,
  //@ts-ignore
  delegateAuthority: this.publicKey,
}).toTransaction(latestBlockhash);

const delegatenft2 = this.metaplex.tokens().builders().approveDelegateAuthority({
  mintAddress: nftMint2,
  //@ts-ignore
  delegateAuthority: this.publicKey,
}).toTransaction(latestBlockhash);

const transaction = new Transaction().add(delegatenft1, delegatenft2, ...)

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.