I am trying to write a function that would allowed the first 2000 mint are free and then the contract stop until i start the public mint.

it would be be like two public mint, i guess.

thank you in advance.

1 Answer 1


In your mint function you check if the current token id is less than 2000, if it is you dont charge any price, otherwise you charge the price. Example:

function mint(uint256 _amnt) public payable {
    uint256 alreadyMinted = totalSupply(); // see how many have already been minted
    if (alreadyMinted + _amnt >= 2000) {
        require(msg.value >= _amnt * cost);
    for (uint256 i = 1; i <= _amnt;i++) {
        _safeMint(msg.sender, alreadyMinted + i); // mint the user there nft

Im sure this can probably be cleaned up / optimised but this is a simple example.

  • 1
    And you can probably add a onlyOwner modifiable activeSell boolean for activating public mint after pre-mint, it will allow you to control starting of payable mints.
    – CP3c0
    Feb 15, 2022 at 16:17
  • Thank you so much @nemo for your quick reply and help. I going to run some test.
    – Ed C.
    Feb 15, 2022 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.