Class: MerkleTree
merkle.MerkleTree
Constructors​
constructor​
• new MerkleTree(leafHashes, hashMethod?): MerkleTree
Create a Merkle tree
Parameters​
| Name | Type | Default value | Description |
|---|---|---|---|
leafHashes | string[] | undefined | hex-string array |
hashMethod | (a: BigNumberish, b: BigNumberish) => string | computePedersenHash | hash method to use, default: Pedersen |
Returns​
created Merkle tree
Example
const leaves = ['0x1', '0x2', '0x3', '0x4', '0x5', '0x6', '0x7'];
const tree = new MerkleTree(leaves);
// tree = {
// branches: [['0x5bb9440e2...', '0x262697b88...', ...], ['0x38118a340...', ...], ...],
// leaves: ['0x1', '0x2', '0x3', '0x4', '0x5', '0x6', '0x7'],
// root: '0x7f748c75e5bdb7ae28013f076b8ab650c4e01d3530c6e5ab665f9f1accbe7d4',
// hashMethod: [Function computePedersenHash],
// }
Defined in​
Properties​
leaves​
• leaves: string[]
Defined in​
branches​
• branches: string[][] = []
Defined in​
root​
• root: string
Defined in​
hashMethod​
• hashMethod: (a: BigNumberish, b: BigNumberish) => string
Type declaration​
â–¸ (a, b): string