Skip to content

SolidityUniversity/merkle-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Merkle Tree Generator (OpenZeppelin)

This script creates a Merkle Tree using the OpenZeppelin Merkle Tree library and allows you to generate a Merkle proof for a given address and amount.

πŸš€ Usage

0. Install dependencies

yarn install

1. Create a Merkle Tree

node merkle-tree.js

This will generate a tree.json file and print the Merkle Root.

2. Generate Proof for a Value

You can get the Merkle proof for a specific address and amount:

node merkle-tree.js proofValue <address> <amount>

Example:

node merkle-tree.js proofValue 0x1234567890abcdef1234567890abcdef12345678 11

If the value exists in the tree, it will print the proof.

πŸ§ͺ Example Data

The default data in the script is:

[
  ["0x1234567890abcdef1234567890abcdef12345678", "11"],
  ["0xabcdefabcdefabcdefabcdefabcdefabcdefabcd", "22"]
]

You can modify this values array to suit your needs.

πŸ“ Output

  • tree.json: contains the full Merkle Tree structure
  • console.log: shows the Merkle Root or proof result

About

Generate and verify Merkle Tree using OpenZeppelin library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published