Practical overview
When it fits
Use it when a JavaScript application needs to construct a Merkle tree and create or check an inclusion proof for one of its leaves.
Who it is for
- JavaScript developers implementing Merkle-tree data structures or proof workflows.
- Blockchain developers who need Merkle roots and leaf proofs in application code.
- Developers who need to validate a proof against a known target hash and root.
Documented uses
- Add one or more values as Merkle-tree leaves, optionally hashing input values first.
- Build a tree and retrieve its root.
- Generate a proof for a leaf by index.
- Check whether a proof connects a target hash to a Merkle root.
Requirements & limits
The repository provides npm installation instructions and identifies the project as Apache-2.0 licensed.
- The default hash type is SHA-256; the README also lists SHA, SHA3, and other crypto hash algorithms.
- Leaves must be Buffers or hexadecimal strings unless the optional doHash setting is used to hash other values.
- The standard
makeTree()behavior promotes a lone leaf node to the next level. - The separate
makeBTCTree()method is described as reproducing a flawed Bitcoin Merkle-tree implementation and is intended only when that behavior must be replicated.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Install Merkle Tools and prepare a tree
Add the npm package to a JavaScript project, create a MerkleTools instance, add leaves, and build a tree.
Before you start
- A JavaScript project using npm.
- Leaves supplied as Buffers or hexadecimal strings, or other values with the doHash option enabled.
Steps
Install the package with the command below.
npm install --save merkle-toolsLoad it with
var MerkleTools = require('merkle-tools')and create an instance; the default hash type is SHA-256.Add individual leaves or an array of leaves, enabling doHash for values that are not Buffers or hexadecimal strings.
Call
makeTree()to build the tree.
Expected outcome
The instance has a built tree and can provide its Merkle root and leaf proofs.
Guide limitations
- The documented workflow uses JavaScript and npm.
- Adding leaves or resetting the tree makes it not ready until it is built again.
Generate and validate a leaf proof
Retrieve a proof for a leaf in a built tree and check whether it connects a target hash to a Merkle root.
Before you start
- A MerkleTools instance with leaves added and the tree built.
- A target hash and Merkle root represented as Buffers or hexadecimal strings for validation.
Steps
Build the tree with
makeTree().Call
getProof(index)for the leaf's index.Pass the proof, target hash, and Merkle root to
validateProof(proof, targetHash, merkleRoot).
Expected outcome
Validation returns a boolean indicating whether the proof connects the target hash to the supplied root.
Guide limitations
- The tree must be ready and the requested leaf index must exist; otherwise
getProofreturns null. - For Bitcoin-style double hashing, the matching double-hash setting must be used during tree construction and proof validation.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 16 October 2026
- Original website title
- Tierion/merkle-tools · Official homepage title · retained in its source language

