Skip to content

Commit

Permalink
add js merkle proof script
Browse files Browse the repository at this point in the history
  • Loading branch information
FredCoen committed Apr 11, 2022
1 parent bb39507 commit e218970
Show file tree
Hide file tree
Showing 3 changed files with 1,129 additions and 5 deletions.
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { MerkleTree } = require('merkletreejs')
const keccak256 = require('keccak256')
// Input whitelist adresses
const whiteList = ['address_one', 'address_two']

const leaves = whiteList.map(address => keccak256(address))
const tree = new MerkleTree(leaves, keccak256, {sortPairs:true})
const leaf = 'address_one'
const proof = tree.getHexProof(keccak256(leaf))
console.log("Merkle root:", tree.getHexRoot())
console.log("Merkle proof:", proof)
Loading

0 comments on commit e218970

Please sign in to comment.