Mint Site - Merkle Tree

Hello -

I am trying to add the merkle tree to my smart contract for whitelist. I have the part where I created the whitelist, can run the standalone javascript app, get the roothash, add it to the contract, and confirm the merklehash with the respected whitelisted address.

I am using the Hashlips Minting Dapp, which does not have the functionality for the merkleproof/whitelist - has anyone added the merkleproof to his minting dapp? Or is there another one out there that is available?

If not, im guessing im going to need to create a Javascript API running the merkletree/proof, and somehow adapt the minting dapp to get the merkleproof for the users address, and adapt the send function to send to the whitelist mint.

any help would be great!

thanks in advance

Did you still need help?

Yes pl do share it , thanks in advance

https://github.com/armanmamyan/merkle-tree -- Merkle Tree
https://github.com/armanmamyan/smart-contract-creator/blob/main/templates/ERC721AStandardWithMerkle.sol -- Merkle Tree Smart Contract

You need to install merkletreejs and keccak256 in Your minting Dapp.

Then Put the following code.

const merkleConfig = {
  sortPairs: true,
};

const whitelistAddressList = [
    "0x8Fa461074FC99D7B874569869b2559Addd00d9AD",
    "0xB92CCc983DFdbB0E22303031d772513C7D5692b7",
]

const lowercaseWL = whitelistAddressList.map((item) => item.toLowerCase());

// // Variables
let leafNodeList;
let merkleTree;
let rootHash;

// // Creating new array with hashing all whitelist addresses using keccak256
leafNodeList = lowercaseWL.map((address) => keccak256(address));
// // Creating Merkle Tree algorithm using keccak256
merkleTree = new MerkleTree(leafNodeList, keccak256, merkleConfig);

// // log merkleTree with toString() method to see the root hash
rootHash = merkleTree.getRoot();

// console.log(merkleTree.toString());

Inside Mint function do the following way:

 const claimingAddress = leafNodeList[lowercaseWL.indexOf(account.toLowerCase())];
  if (!claimingAddress) return alert("Your are not whitelisted");

 const hexProof = merkleTree.getHexProof(claimingAddress);

  const reformatVerifiedAddress = hexProof.map((item) =>
    item.replace(/["']/g, "")
  );

await preSaleMint(
          reformatVerifiedAddress,
          count,
         {
          value: costOfNft
        }
        );