Skip to content

Generates a Merkle tree from a json file of genes

License

Notifications You must be signed in to change notification settings

vincanger/merkletree_generator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NFgenes 🧬⛓ - Merkle Tree Generator

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'.

To Use

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:

Generate an array of hashed gene symbols and Merkle Tree

$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.

  • Example output array of hashed values

  • Example output Merkle Tree

Generate a Merkle Tree Summary

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

Generate a Merkle Proof

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. merkle proof value selection

The array index value must be passed into the 'generateProof()' function. pass array index value to 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. proof display

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

Resources

This repo is built using:

merkletreejs

merkletreejs-clie

keccak256

Helpful Resources on Merkle Trees

Learn more about the NFgenes 🧬⛓ project

About

Generates a Merkle tree from a json file of genes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%