Skip to content

Instantly share code, notes, and snippets.

@DonkeVerse
Last active June 29, 2022 08:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DonkeVerse/6a0af987dbd15181fdeaef12564ca7ac to your computer and use it in GitHub Desktop.
Save DonkeVerse/6a0af987dbd15181fdeaef12564ca7ac to your computer and use it in GitHub Desktop.
function benchmark1Mapping() external {
    require(allowList[msg.sender] == 1, "not allowed");
   // business logic
}

function benchmark2PublicSignature(bytes calldata _signature) external {
    require(
        allowListSigningAddress ==
            keccak256(
                abi.encodePacked(
                    "\x19Ethereum Signed Message:\n32",
                    bytes32(uint256(uint160(msg.sender)))
                )
            ).recover(_signature),
        "not allowed"
    );
    // business logic
}

function benchmark3MerkleTree(bytes32[] calldata merkleProof) external {
    require(
        MerkleProof.verify(merkleProof,
            merkleRoot,
            keccak256(
                abi.encodePacked(msg.sender))),
        "not allowed");
    // business logic
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment