-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateMerkleTree.js
More file actions
23 lines (19 loc) · 948 Bytes
/
createMerkleTree.js
File metadata and controls
23 lines (19 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { StandardMerkleTree } from "@openzeppelin/merkle-tree";
import fs from "fs";
// (1)
const values = [
["0x0000000000000000000000000000000000000001", "0", "10000000000000000000"],
["0x0000000000000000000000000000000000000002", "1", "20000000000000000000"],
["0x0000000000000000000000000000000000000003", "2", "30000000000000000000"],
["0x0000000000000000000000000000000000000004", "3", "40000000000000000000"],
["0x0000000000000000000000000000000000000005", "4", "50000000000000000000"],
["0x0000000000000000000000000000000000000006", "5", "60000000000000000000"],
["0x0000000000000000000000000000000000000007", "6", "70000000000000000000"],
["0x0000000000000000000000000000000000000008", "7", "80000000000000000000"],
];
// (2)
const tree = StandardMerkleTree.of(values, ["address", "uint256", "uint256"]);
// (3)
console.log("Merkle Root:", tree.root);
// (4)
fs.writeFileSync("tree.json", JSON.stringify(tree.dump()));