Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
This contract has been partially verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- MerkleVerifier
- Optimization enabled
- true
- Compiler version
- v0.8.17+commit.8df45f5f
- Optimization runs
- 800
- EVM Version
- london
- Verified at
- 2026-05-23T00:24:14.637672Z
contracts/lib/MerkleVerifier.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
/**
* @title MerkleVerifier
* @dev Utility functions for Merkle tree computations
*/
library MerkleVerifier {
error InvalidProof();
/**
* @dev Verify the merkle proof
* @param leaf leaf
* @param root root
* @param proof proof
*/
function _verifyProof(
bytes32 leaf,
bytes32 root,
bytes32[] memory proof
) public pure {
bytes32 computedRoot = _computeRoot(leaf, proof);
if (computedRoot != root) {
revert InvalidProof();
}
}
/**
* @dev Compute the merkle root
* @param leaf leaf
* @param proof proof
*/
function _computeRoot(
bytes32 leaf,
bytes32[] memory proof
) public pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
computedHash = _hashPair(computedHash, proofElement);
}
return computedHash;
}
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
}
function _efficientHash(
bytes32 a,
bytes32 b
) private pure returns (bytes32 value) {
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
Compiler Settings
{"remappings":[],"optimizer":{"runs":800,"enabled":true},"metadata":{"bytecodeHash":"none"},"libraries":{},"evmVersion":"london","compilationTarget":{"contracts/lib/MerkleVerifier.sol":"MerkleVerifier"}}
Contract ABI
[{"type":"error","name":"InvalidProof","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"_computeRoot","inputs":[{"type":"bytes32","name":"leaf","internalType":"bytes32"},{"type":"bytes32[]","name":"proof","internalType":"bytes32[]"}]},{"type":"function","stateMutability":"pure","outputs":[],"name":"_verifyProof","inputs":[{"type":"bytes32","name":"leaf","internalType":"bytes32"},{"type":"bytes32","name":"root","internalType":"bytes32"},{"type":"bytes32[]","name":"proof","internalType":"bytes32[]"}]}]
Contract Creation Code
0x6102cb61003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100405760003560e01c806372aaadac146100455780639c7bf9381461005a575b600080fd5b6100586100533660046101ea565b61007f565b005b61006d61006836600461023a565b6100b3565b60405190815260200160405180910390f35b600061008b84836100b3565b90508281146100ad576040516309bde33960e01b815260040160405180910390fd5b50505050565b600082815b83518110156100ff5760008482815181106100d5576100d5610281565b602002602001015190506100e98382610107565b92505080806100f790610297565b9150506100b8565b509392505050565b6000818310610123576000828152602084905260409020610132565b60008381526020839052604090205b9392505050565b634e487b7160e01b600052604160045260246000fd5b600082601f83011261016057600080fd5b8135602067ffffffffffffffff8083111561017d5761017d610139565b8260051b604051601f19603f830116810181811084821117156101a2576101a2610139565b6040529384528581018301938381019250878511156101c057600080fd5b83870191505b848210156101df578135835291830191908301906101c6565b979650505050505050565b6000806000606084860312156101ff57600080fd5b8335925060208401359150604084013567ffffffffffffffff81111561022457600080fd5b6102308682870161014f565b9150509250925092565b6000806040838503121561024d57600080fd5b82359150602083013567ffffffffffffffff81111561026b57600080fd5b6102778582860161014f565b9150509250929050565b634e487b7160e01b600052603260045260246000fd5b6000600182016102b757634e487b7160e01b600052601160045260246000fd5b506001019056fea164736f6c6343000811000a
Deployed ByteCode
0x734c2bbdbeccae1c492c681158a46eae498a05627b30146080604052600436106100405760003560e01c806372aaadac146100455780639c7bf9381461005a575b600080fd5b6100586100533660046101ea565b61007f565b005b61006d61006836600461023a565b6100b3565b60405190815260200160405180910390f35b600061008b84836100b3565b90508281146100ad576040516309bde33960e01b815260040160405180910390fd5b50505050565b600082815b83518110156100ff5760008482815181106100d5576100d5610281565b602002602001015190506100e98382610107565b92505080806100f790610297565b9150506100b8565b509392505050565b6000818310610123576000828152602084905260409020610132565b60008381526020839052604090205b9392505050565b634e487b7160e01b600052604160045260246000fd5b600082601f83011261016057600080fd5b8135602067ffffffffffffffff8083111561017d5761017d610139565b8260051b604051601f19603f830116810181811084821117156101a2576101a2610139565b6040529384528581018301938381019250878511156101c057600080fd5b83870191505b848210156101df578135835291830191908301906101c6565b979650505050505050565b6000806000606084860312156101ff57600080fd5b8335925060208401359150604084013567ffffffffffffffff81111561022457600080fd5b6102308682870161014f565b9150509250925092565b6000806040838503121561024d57600080fd5b82359150602083013567ffffffffffffffff81111561026b57600080fd5b6102778582860161014f565b9150509250929050565b634e487b7160e01b600052603260045260246000fd5b6000600182016102b757634e487b7160e01b600052601160045260246000fd5b506001019056fea164736f6c6343000811000a