miguelmota/merkletreejs-solidity
Construct merkle trees with MerkleTree.js and verify merkle proofs in Solidity.
🔐 Merkle Tree trên Solidity – Xác minh proof từ JS đến smart contract
Kết hợp MerkleTree.js để tạo cây và Solidity để verify – đầy đủ ví dụ và test.
Đây là ví dụ minh họa cách xây dựng Merkle tree bằng MerkleTree.js ở phía client (JavaScript), đồng thời triển khai hàm xác minh proof (verify) trong Solidity để dùng trên blockchain Ethereum.
✨ Điểm nổi bật
- MerkleProof.verify: Hàm Solidity kiểm tra proof so với root, trả về true/false.
- So sánh hash tự động: Dùng
keccak256vàabi.encodePackedđể ghép hash theo thứ tự nhỏ/lớn. - Hỗ trợ proof mảng: Nhận đầu vào là root, leaf, và mảng proof.
- Ví dụ JS đầy đủ: Dựng tree từ danh sách leaves, lấy root, leaf, proof và gọi verify.
- Kiểm tra sai số: So sánh proof đúng và proof sai để chứng minh tính chính xác.
- Dễ chạy test: Dùng
make testđể thực thi toàn bộ quy trình.
💡 Vì sao đáng chú ý
Dự án cung cấp đầy đủ đoạn code từ phía JS đến Solidity, giúp người mới dễ dàng hiểu và triển khai nhanh. Phù hợp để xây dựng hệ thống airdrop, whitelist, hoặc bất kỳ ứng dụng nào cần kiểm chứng dữ liệu bằng Merkle proof trên blockchain.
#MerkleTree #Solidity #Ethereum #SmartContracts #TiniX
Similar Projects
Discover other similar projects and AI models.
Go Merkle Tree. High performance, Supporting parallel run, OpenZeppelin sorting pairs.
OpenZeppelin Contracts is a library for secure smart contract development.
Mastering Ethereum: 2nd Edition, by Andreas M. Antonopoulos, Gavin Wood, Carlo Parisi, Alessandro Mazza, Niccolò Pozzolini
DeFi Developer roadmap is a curated Developer handbook which includes a list of the best tools for DApps development, resources and references!
Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
A guide to smart contract security best practices
Lightweight Java and Android library for integration with Ethereum clients
Mythril is a symbolic-execution-based securty analysis tool for EVM bytecode. It detects security vulnerabilities in smart contracts built for Ethereum and other EVM-compatible blockchains.