Skip to content

0x-ultra/simple-merkle-tree-whitelist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Merkle Tree Whitelist

Quick utility for generating a json file containing all proofs for a tree given a list of wallets to add to the merkle tree.
Can be used for smart contract whitelisting purposes in applications where no value parameter is needed besides a msg.sender

Usage

Insert your wallet addresses in the whitelist.json file following the example format.

npm install
node main.js

This will generate a proofs.json file containing all proofs for the tree. The merkle root is also printed in the console.

Verifier

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";

contract Verifier {
    bytes32 private root;

    constructor(bytes32 _root) {
        root = _root;
    }

    function verify(
        bytes32[] memory proof
    ) public returns(bool){
        bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(msg.sender))));
        require (MerkleProof.verify(proof, root, leaf), "Proof not valid");
    }
}

About

Simple merkle tree generator utility

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published