merkle-tree-typescript
v1.1.2
Published
Fast, zero-dependency Merkle tree implementation in TypeScript. Proof generation, verification, multi-proofs. RFC 6962 and OpenZeppelin EVM compatible.
Maintainers
Readme
merkle-tree-typescript
Fast, zero-dependency Merkle tree in TypeScript. Proof generation, verification, and multi-proofs. Compatible with RFC 6962 and OpenZeppelin EVM smart contracts.
Install
npm install merkle-tree-typescriptQuick Start
import { MerkleTree } from 'merkle-tree-typescript';
// 1. Create a tree
const tree = new MerkleTree(['Alice', 'Bob', 'Charlie', 'Dave']);
// 2. Generate a proof for a leaf
const proof = tree.getProof('Charlie');
// 3. Verify the proof
console.log(tree.verify(proof)); // trueFeatures
- Zero Runtime Dependencies: Ultra-lightweight, pure TypeScript with hardware-accelerated WebCrypto & Node crypto.
- Universal Runtime: Runs anywhere — Node.js, Browsers, React Native, Cloudflare Workers, Deno, Bun.
- Web3 & EVM Ready: Full OpenZeppelin
sortPairsand double-hashing compatibility. - Cryptographically Secure: RFC 6962 domain separation prevents second-preimage attacks.
- Multi-Proof Verification: Batch verify multiple leaves in a single compact proof.
- Tree Diffing: $O(\log n)$ change detection between tree versions.
- CLI Built-in: Hash and verify file directories directly with
npx merkle-tree-typescript.
Documentation
- API Reference — Complete class, method, and option documentation
- Merkle Proofs Guide — How proofs, multi-proofs, and sorted pairs work
- Examples & Recipes — Web3 airdrops, audit logs, file verification
- Security & RFC 6962 — Vulnerability mitigations and cryptographic guarantees
- Benchmarks — Performance metrics and throughput data
- Interactive Visualizer & Explorer — Live web playground
License
MIT (c) 2022-2026 Lucas Armstrong
