Skip to content

Instantly share code, notes, and snippets.

@DonkeVerse
Last active January 7, 2022 06:29
Show Gist options
  • Save DonkeVerse/46487a85a13d01ba16f919004c33b557 to your computer and use it in GitHub Desktop.
Save DonkeVerse/46487a85a13d01ba16f919004c33b557 to your computer and use it in GitHub Desktop.
mapping (address => uint256) public alreadyMinted;
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 {
    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(alreadyMinted[msg.sender] < 2, "too many");
    require(msg.value == PRICE, "wrong price");

    alreadyMinted[msg.sender]++;
    totalSupply++;
    _safeMint(msg.sender, totalSupply - 1);
}
|  Methods                              · 
···············|························|·············|··············|
|  Contract    ·  Method                ·  Min        ·  Max         · 
···············|························|·············|··············|
|  GasContest  ·  publicMint            ·      73679  ·      107879  ·
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment