metaplex-foundation / metaplex

A directory of what the Metaplex Foundation works on!
https://metaplex.com
Apache License 2.0
3.32k stars 6.26k forks source link

Adding option to mint multiple tokens at once? #363

Closed WilliamRT95 closed 2 years ago

WilliamRT95 commented 3 years ago

Will be great almost necessary to let people mint multiple tokens if they wanted to. As far as I'm concerned we only have the option of "mint_one_token".

Thank you!

ozyman42 commented 3 years ago

In theory we should be able to create one transaction with multiple calls to mint one token, right?

WilliamRT95 commented 3 years ago

As far as Im concerned you have to implement "const signedTxns = await wallet.signAllTransactions(unsignedTxns);" metaplex already has in their marketplace. Will be great if they can implement that to use outside their marketplace. For now we are stuck with mint_one_token, unless you implement it yourself.

kevinfaveri commented 3 years ago

Hello guys, I've just implemented it in my repo (mintMultipleToken, which receives a param called quantity). It will be multiple transactions but the user will only be prompted once. Check it here: https://github.com/kevinfaveri/solana-candy-factory/blob/main/src/utils/candy-machine.ts#L332

ozyman42 commented 3 years ago

Hello guys, I've just implemented it in my repo (mintMultipleToken, which receives a param called quantity). It will be multiple transactions but the user will only be prompted once. Check it here: https://github.com/kevinfaveri/solana-candy-factory/blob/main/src/utils/candy-machine.ts#L332

Is the whole thing atomic? Meaning it will either all succeed or all fails? Are there scenarios where some fail and others do not? If so how do you track that? This looks promising.

kevinfaveri commented 3 years ago

It is not atomic, it creates multiple instructions and then sends multiple transactions. However, it does it all on a single signature, meaning the user will only receive a single popup (and not 5 if they are minting five). Since it generates X number of transactions (one for each NFT you want to mint), you can just listen to these transactions to check if they succeeded or failed.

ozyman42 commented 3 years ago

I noticed that Solflare throws a runtime error when trying to call signAllTransactions on the txns generated by your code.

kevinfaveri commented 3 years ago

Hey @AlexLeung yeah it might because it does not support big instructions. This is why this is a partial workaround right now, it does not change the fact that the candy machine could implement a program function for that

ozyman42 commented 3 years ago

All of a sudden started getting this error from Phantom.

Transaction failed: You cannot unilaterally verify another creator, they must sign

you seeing this too?

devtimnbr commented 3 years ago

All of a sudden started getting this error from Phantom.

Transaction failed: You cannot unilaterally verify another creator, they must sign

you seeing this too?

Also got this error all of a sudden.

ozyman42 commented 3 years ago

I'm assuming Phantom pushed a new update that has an additional validation it once didn't

swagzhang commented 3 years ago

did u guys fix the problem? I suddenly met same problem, after I mint 16 nfts

ozyman42 commented 3 years ago

phantom-ticket

Perhaps a long-shot but I requested that Phantom roll-back to prevent adversely affecting the Solana NFT ecosystem. I don't have time to debug this right now. Please post if you guys figure it out.

ozyman42 commented 3 years ago
{
    "InstructionError": [
        4,
        {
            "Custom": 54
        }
    ]
}

there's actually a chance this is coming from Candy Machine itself

ozyman42 commented 3 years ago

611 has this issue

Perhaps #609 is related

ozyman42 commented 3 years ago

fixed by https://github.com/metaplex-foundation/metaplex/pull/614

jordaaash commented 3 years ago

Thanks @AlexLeung. Closing as this has been reported fixed. Please comment if it's still affecting you.

ozyman42 commented 3 years ago

I don't think the original purpose of the issue has been fixed. @jordansexton the issue and fix I mentioned was for an unrelated issue which I originally assumed was related to the temporary code fix which @kevinfaveri provided. Overall this issue is still open until the candy machine smart contract itself supports multiple mints per call.

jordaaash commented 3 years ago

Got it. Thanks for clarifying.

Yuriy-Ihor commented 3 years ago

It is not atomic, it creates multiple instructions and then sends multiple transactions. However, it does it all on a single signature, meaning the user will only receive a single popup (and not 5 if they are minting five). Since it generates X number of transactions (one for each NFT you want to mint), you can just listen to these transactions to check if they succeeded or failed.

Man I haven't tested it yet, but if it works, I love you ❤️❤️❤️ (even if it's not, I still appreciate your work :) )

Rakeshpradhan1999 commented 3 years ago

Can anyone guide me how to setup this https://github.com/kevinfaveri/solana-candy-factory on locally , I am getting error

Rakeshpradhan1999 commented 3 years ago

I want only multiple minting function please guide me if anyone can

cdric commented 2 years ago

Hey guys. I was able to add support for multiple mints at once (using a similar implementation to the one provided in the Next Candy machine - https://github.com/maxwellfortney/next-candy-machine).

However, since this is sending 5x instructions per mint (5 for 1 mint, 10 for 2 mints, 15 for 3 mints, and so on) to the wallet provided. For some reason the Phantom wallet provide isn't able to compute the transaction cost once the number of instructions exceeds 2 mints (or ~10 instructions). As such the max number of mint I can offer to our users is 2. After that, they won't know how much will be taken from their wallet which is gonna raise a red flag more than anything else (even though the transaction would go through if they approve it). We just can't go live with this limitation.

Also, this seems to be a wallet-specific issue, as with Solflare, the wallet provider breaks down each mint transaction so the user can review that.

From a high level, these are hacks IMHO that have obvious limitations (2 mint max). It would be great if the Metaplex team can provide a native implementation of multiple mints so we don't have to rely on these workarounds that aren't very stable.

Is the Metaplex team considering adding this future in the near future?

Thanks!

github-actions[bot] commented 2 years ago

This Issue has received no activity for 30 days. We will close it in 2 days, please reopen if you are still experiencing this issue.

github-actions[bot] commented 2 years ago

This Issue has received no activity for 30 days. We will close it in 2 days, please reopen if you are still experiencing this issue.