Berry Blue
Berry Blue

Reputation: 16492

How do you mint multiple tokens in a single transaction in Metaplex Candy Machine v2?

Is it possible to mint multiple tokens in a single transaction?

I've found this code in the candy machine repo to mint one NFT in a transaction.

https://github.com/metaplex-foundation/candy-machine-ui/blob/main/src/candy-machine.ts#L371

Upvotes: 1

Views: 1305

Answers (1)

Mark Sackerberg
Mark Sackerberg

Reputation: 838

You can never mint multiple NFTs through candy machine in a single transaction. The on chain program does not allow this.

What you can do is have the user sign multiple Transaction at the same time (user has to confirm once) and send them all at once to the Solana RPC.

for this you have to

  1. Build multiple transactions (run the existing function multiple times) and push them into an array
  2. use signAllTransactions to have the user sign all transactions at the same time
  3. Send the transactions to the network
  4. Confirm that/if all transactions go throug.

It is absolutely possible but involves some quite heavy changes in the UI logic

Upvotes: 2

Related Questions