Skip to content

Instantly share code, notes, and snippets.

@loocurse
Last active April 8, 2022 04:48
Show Gist options
  • Save loocurse/96d7f7cb12fdbe17790c7a896ff355db to your computer and use it in GitHub Desktop.
Save loocurse/96d7f7cb12fdbe17790c7a896ff355db to your computer and use it in GitHub Desktop.
... // import statements
contract MyToken is ERC721, Ownable {
// vars
function _convertLeaf(address _user, uint256 _quantity)
internal
pure
returns (bytes32)
{
string memory quantity_string = Strings.toString(_quantity);
string memory address_string = Strings.toHexString(
uint256(uint160(_user)),
20
);
return keccak256(abi.encodePacked(quantity_string, address_string));
}
function preSaleMint(uint256 _quantity, bytes32[] calldata _proof, uint256 _maxQuantity, bytes32 _leaf) external payable callerIsUser {
...
require(
_convertLeaf(msg.sender, _maxQuantity) == _leaf,
"LEAF NODE AND QUANTITY DO NOT MATCH"
);
bool isValidProof = MerkleProof.verify(
_proof,
preSaleMerkleRoot,
_leaf
);
require(isValidProof, "INVALID PROOF");
... // implementation here
_safeMint(msg.sender, _quantity);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment