Skip to content

Instantly share code, notes, and snippets.

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

function publicMint(bytes calldata _signature) external payable {
    uint256 _totalSupply = totalSupply;
    require(_totalSupply < MAX_SUPPLY, "max supply");
    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");

    _mint(msg.sender, _totalSupply);
    unchecked {
        _totalSupply++;
    }
    totalSupply = _totalSupply;
}
·---------------------------------------|---------------------------|
|         Solc version: 0.8.10          ·  Optimizer enabled: true  ·
········································|···························|
|  Methods                                                           
···············|························|·············|·············|
|  Contract    ·  Method                ·  Min        ·  Max        ·
···············|························|·············|·············|
|  GasContest  ·  publicMint            ·      64219  ·      81319  ·
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment