I want to hand out at an in-person event a door prize for NFTs. Many people will not be familiar with crypto at all and this can be their entrance. It should be a piece of paper but could be a QR code or a redemption code but probably not longer than 16-20 characters. I want to create a Dapp where they can install a wallet, enter the code and become the owner of the NFT. I will also be glad to pay the gas so they do not need any eth right away.
I am fine with creating the ERC721 contract ( thanks openzepplin wizard ) but I think my Dapp should interact with another contract that does the transfer.
Has this been done ? Any pointers on how to make this secure ?
Hey, I'm looking for something like the OP, earlier I looked into the video and tried some options from the workshop repo. I was thinking of using the merkle solution - but realised that I would have to use a backend service to provide the proof to the frontend, to not reveal other mint codes.
Is there a similar method where I wouldn't have to expose the access codes?
The solution you found in https://github.com/a16z/zkp-merkle-airdrop-contracts achieves more than what I think you want. The goal of that project is to try to anonimize users / avoid them doxing their own account. From your description I don't think that's what you're looking for.
Here's what I think you can do. You can publish the entire merkle tree publicly, where each leaf of the tree corresponds to a mint code. A mint code will contain a hash, and in order to redeem that mint code you have to present the preimage of that hash, along with the merkle proof. In this way the merkle proof on its own is not enough to redeem, and you can publish the merkle tree without revealing everything.
In your treasure hunt, the "treasures" would be the preimages, and you would have a dapp (or some other way) to generate the merkle proof for the corresponding mint code.
Something you need to be careful about is frontrunning. The simplest way to mitigate frontrunning is for users (or your dapp) to redeem using Flashbots RPC. This is not 100% safe but is an easy and cheap mitigation. The 100% safe way requires a commit-reveal scheme where users can first claim that they know a mint code preimage by submitting a hash of the preimage along with their address in a first transaction, and after a short while they can submit the mint code and proof in the clear to finally claim it.
Thanks, I misunderstood that part in the workshop example! And as you described the claim + reveal scheme can prevent frontrunning. Thanks for the explanation!