This utility generates a Merkle tree from a provided list of genes in a json file called 'NFgenesList.json'. The Merkle tree will be automatically generated and stored in 'MerkleTree.txt'.
yarn or npm install
The 'NFgenesList.json' file must be a JSON array of gene symbols. Once the 'NFgenesList.json' file is populated with the data, run:
$node generateHashArrayFile.js
Once the above command is run:
-
The file 'MerkleLeaves.json' will be created or overwritten to contain a json array of hexadecimal values representing the keccak256 hash of each gene in the source list.
-
The file 'MerkleTree.txt' will be created or overwritten to contain the generated Merkle Tree of the json array contained in the 'hashArray.json' file.
-
The file 'MerkleTreeRoot.txt' will be created or overwritten to contain the Merkle Tree root hash. This will be used to store in our NFgenes minting contract to perform a check against the valid list of NFgenes that are available to mint.
Running the below script will generate a summary containing each leaf value with its corresponding keccak256 hash and leaf index. This is useful when you want to generate a proof. You can quickly determine which value and corresponding hash and index is necessary.
node generateTreeSummary.js
The below script will generate a Merkle Proof file containing necessary information to pass into the VPBM contract. Simply copy and past the contents of the file into the calldata.
You will need to select a value available in the 'MerkleLeaves.json' file first.
The array index value must be passed into the 'generateProof()' function.
A file containing the Merkle Proof that can be copy and pasted into the contract function argument will be saved to 'MerkleTreeProof.txt'.
The command line will also display the proof information.
node generateMerkleProof.js
To generate a Merkle tree and view via command line (this will not generate a file), use:
cat MerkleLeaves.json | merkletreejs --leaves=- --hash=keccak256 --output=tree
- OpenZeppelin Merkle Proof Contract Library
- merkletreejs Library
- Smart Contract Programmer - Merkle Trees
- Using Merkle Trees for NFT Whitelists
Learn more about the NFgenes 🧬⛓ project