Hey everyone, I need some help with my NFT project!
I’m working on a dApp using React and Node.js for minting tokens from my ERC721 collection. The thing is, I want to make sure people can only mint through my app, not by talking to the smart contract directly.
I know I need to sign the minting requests and check them in the contract, but I’m a bit lost on the details. How do I actually sign stuff in my React app and then verify it in the Solidity code?
If anyone’s done this before, I’d really appreciate some pointers! Maybe a quick code example or just a general explanation of the process? Thanks in advance!
yo, i’ve dealt with this before. u gotta use somethin called merkle proofs. basically, u make a list of allowed addresses, hash em into a merkle tree, and put the root in ur contract. then when mintin, users gotta provide a proof. its pretty slick for controllin access without huge gas costs
I’ve implemented something similar in one of my projects. The key is to use off-chain signatures. In your React app, you’ll need to sign a message (including details like the user’s address and a nonce) using ethers.js or web3.js. Then, send this signature along with the minting request to your contract.
On the contract side, you’ll use ecrecover to verify the signature. Only allow minting if the signature is valid and comes from your designated signer address. This ensures only your dApp can initiate mints.
Remember to include a nonce or timestamp in the signed message to prevent replay attacks. Also, consider rate limiting or other anti-bot measures for added security.
It’s a bit complex to set up, but once working, it’s quite effective at restricting minting to your interface.
hey there LiamDragon22! i’m kinda curious about your project, sounds pretty cool. have u considered using a whitelist approach? it’s not exactly what u asked, but might be worth looking into
basically, u could set up a whitelist of addresses in ur contract, and only let those mint. you’d need to update the list manually or thru admin functions, but it gives u tight control. plus, u could combine it with a time-based release to create hype
btw, how big is ur collection gonna be? and what’s the theme? always love hearing about new nft ideas!
oh, and totally random, but have u thought about doing some kinda community event around the launch? could be a fun way to build buzz and make sure ur biggest supporters get in on the mint