This Solidity project demonstrates how to use a Merkle Tree data structure to implement a whitelist mechanism for a smart contract. Instead of storing addresses in storage memory, which can be expensive in terms of gas fees, this approach leverages the efficiency and security of Merkle Trees.
Example of using Merkle Tree could be found in test
folder.
Utility functions stored in scripts
folder.
Method | Total Gas Cost |
---|---|
Without Merkle Tree | 20,000 * N |
With Merkle Tree | 20,000 (const) |
Method | Total Gas Cost |
---|---|
Without Merkle Tree | 2,518 |
With Merkle Tree | 4,652 |
- After cloning the project install the dependencies:
pnpm i
- Run tests
npx hardhat test