Question : Verify whitelist solidity
Answered by : dejan-ilic
function verifyWhitelist(bytes32 leaf, bytes32[] memory proof) private view returns (bool) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash < proofElement) { computedHash = keccak256( abi.encodePacked(computedHash, proofElement) ); } else { computedHash = keccak256( abi.encodePacked(proofElement, computedHash) ); } } return computedHash == _merkleRoot; }
Source : | Last Update : Tue, 28 Jun 22