Skip to content

Instantly share code, notes, and snippets.

@DonkeVerse
Last active January 7, 2022 06:31
Show Gist options
  • Save DonkeVerse/93a054bece40ae5a6f41742edcfde83c to your computer and use it in GitHub Desktop.
Save DonkeVerse/93a054bece40ae5a6f41742edcfde83c to your computer and use it in GitHub Desktop.
uint256 constant public MAX_SUPPLY = 7778;
uint256 constant public PRICE = 0.06 ether;
bool public enablePublicMint = true;
uint256 public totalSupply = 1;
address private publicMintingAddress;

function publicMint(bytes calldata _signature) external payable {
    uint256 _totalSupply = totalSupply;
    require(_totalSupply < MAX_SUPPLY, "max supply");
    require(enablePublicMint, "public mint enabled");
    require(msg.sender == tx.origin, "no bots");
    require(publicMintingAddress ==
        bytes32(uint256(uint160(msg.sender)))
            .toEthSignedMessageHash()
            .recover(_signature),
        "not allowed"
    );
    require(balanceOf(msg.sender) < 2, "too many");
    require(msg.value == PRICE, "wrong price");

    _safeMint(msg.sender, _totalSupply);
    _totalSupply++;
    totalSupply = _totalSupply;
}
|  Methods                              ·
···············|························|··············|·············|
|  Contract    ·  Method                ·  Min         ·  Max        ·
···············|························|··············|·············|
|  GasContest  ·  publicMint            ·       68182  ·      85282  ·
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment