0

I hope you are all well.

I am trying to make a frontend for an NFT minting DAPP. I use this code for the mint function:

async function mint() {
      if(typeof window.ethereum !== 'undefined') {
        const provider = new ethers.providers.Web3Provider(window.ethereum);
        const signer = provider.getSigner();
        const contract = new ethers.Contract(address, ABI, signer);
        
        let addarr = [];
        whitelistAddresses.map(whitelistAddresse => {
          addarr.push(whitelistAddresse.address)
        })

        const leaves = addarr.map(t => keccak256(t));
        const tree = new MerkleTree(leaves, keccak256, { sortPairs: true });
        const leaf = keccak256(accounts[0]);
        const proof = tree.getHexProof(leaf);


        try {
          let overrides = {
            from: accounts[0],
            value: ethers.utils.parseEther((0.01).toString())
          }
          const transaction = await contract.whitelistMint(proof, overrides);
          await transaction.wait();
        }
        catch(err) {
          console.log(err);
        }
      }
    }

When I use this mint function Google Chrome displays this error:

keccak.js:41 Uncaught (in promise) ReferenceError: Buffer is not defined
    at Keccak.update (keccak.js:41:1)
    at keccak256 (keccak256.js:11:1)
    at index.jsx:46:1
    at Array.map (<anonymous>)
    at mint (index.jsx:46:1)
    at onClick (index.jsx:87:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:1)
    at invokeGuardedCallback (react-dom.development.js:4277:1)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4291:1)

I am very surprised because on one of my other NFT minting DAPP it works perfectly and here it does not work.

Have you already encountered this problem?

Thank you for your answer.

Take care

Pierre

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.