-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathGaslessWhitelist.sol
32 lines (26 loc) · 1.26 KB
/
GaslessWhitelist.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.0.0/contracts/utils/cryptography/MerkleProof.sol";
// - A user can get whitelisted , without paying gas fees
// - just sign a message , which is made by keccak256 hashing algorithm
contract Whitelist {
bytes32 public merkleRoot;
constructor(bytes32 _merkleRoot) {
/// provide the merkle root initially which is obtained by using all the address whitelisted
merkleRoot = _merkleRoot;
}
/// @dev to check if the address is in the whitelist
/// @param proof - proof which the user has
/// @param maxAllowanceToMint - max tokens that can be minted
/// @return bool - check the verification is true or not
function checkInWhitelist(
bytes32[] calldata proof,
uint64 maxAllowanceToMint
) public view returns (bool) {
/// keccak256 is a hashing function which can hash any amount of data we provide ,function used for all merkle trees
bytes32 leaf = keccak256(abi.encode(msg.sender, maxAllowanceToMint));
/// internal merkleproof function from openzepplin contract
bool verified = MerkleProof.verify(proof, merkleRoot, leaf);
return verified;
}
}