candypay / nft-sdk

🏄‍♂️ CandyPay NFT SDK lets you effortlessly create NFT minting functions for Candy Machine v2 collections.
https://npmjs.com/package/@candypay/sdk
MIT License
29 stars 7 forks source link

end-user has to sign the transaction when minting in a gassless way #2

Open JuanRdBO opened 2 years ago

JuanRdBO commented 2 years ago

Would it be possible to have the end-user just receive the mint, instead of having to be a signer?

0xMukesh commented 2 years ago

Hey! Can you explain what your use case is? The SDK already has an NFT airdrop function which doesn't require the end-user to sign the transaction. The transaction is being signed via the mint keypair and the payer wallet

https://github.com/candypay/sdk/blob/bfb30790356a6bc0140f527a74cd19b9cf1f1a75/packages/sdk/src/lib/nft-airdrop.ts#L162

0xMukesh commented 2 years ago

Update: The airdrop function's internal types have been changed in the latest version of the SDK. Here is the latest code on how to use the airdrop function - https://github.com/candypay/sdk#airdrop

https://github.com/candypay/sdk/blob/553791e5cfdf22ff10fb16a972930f8929ca076d/packages/sdk/src/types/nft.ts#L7-L57

JuanRdBO commented 2 years ago

Hey! I saw that one, but I was referring to the gasless mint of a candy machine. It would be awesome, if the gassless way would not require the end-user to sign the transaction

0xMukesh commented 2 years ago

Gotcha! The latest update of the SDK doesn't require the end user to sign the transaction for minting the Candy Machine via the gasless method. You can take a look at the test suite for the candyMachine module -- https://github.com/candypay/sdk/blob/main/packages/sdk/tests/candy-machine.test.ts. Under the test for the gasless method, you can see that the transaction is only being signed by the payer wallet and the mint keypair.

https://github.com/candypay/sdk/blob/553791e5cfdf22ff10fb16a972930f8929ca076d/packages/sdk/tests/candy-machine.test.ts#L42-L46

Here is a transaction created via the gasless method's test -- 5c3V3sGLJEU3j3wjJnV1786hhJtLddEcGoikmtPTskXCyhUTkDx1Xxr5xWdi3mJTBWYGUJRhBVGidRnRSzPZ9ywq via the following configuration:

The end-user account on the explorer doesn't show the "Signer" badge beside it, whereas the payer account has both the "Signer" and "Fee Payer" badges beside it

image image