Limit NFT minting by month

Hi,

So I want to mint only 100 NFTs per month, and I want to deploy just one contract how would I go about it? I though of having an ownerOnly manual flag, that can be set:

if (secondMonth)
maximumSupply = 200

if (thirdMonth)
maximumSupply = 300

And so on? Any flaws?,
Thanks!

Are these 100 NFTs evenly spaced in minting time or not? Is there an absolute maximum supply? Who is able to mint the NFTs?

100 per month, if the 100 are minted in a single day is fine.
Yes there is a maximum supply, after a year the max supply should be reached (1200).
Anybody should be able to call the mint function, plus a fee.

If the timeline is not strictly required, then a timelock can be implemented, i.e., there is a strict relationship between tokenIds and timestamps or time elapsed since deployment. Then when mint function is called, check if this condition is met or not.

Ok. It is almost the same check-wise, the main difference is that is automatic and not manual?

uint public constant november = 11 days;
uint public constant december= 41 days;

if (block.timestamp >= november)
maximumSupply = 200
if (block.timestamp >= december)
maximumSupply = 300

1 Like

yes, in the world of blockchain, the spirit is to code the rules in smart contracts instead of executing rules by people. A lot more transparent and thus trustworthy

1 Like

is that the code that would be used? im trying to do the same thing with my collection

Not sure if you figured this out but I was trying to do the same thing and figured out you have to add whatever time interval you want to the initial block.timestamp of your contracts creation. I attached the code below that worked for me.

uint256 deployDate;

constructor() ERC721("Name Of Collection", "NOC") {
        deployDate = block.timestamp;
}

function safeMint(address to, string memory uri) public payable {
        if(block.timestamp >= deployDate + 1 days){
            maxSupply = 1;
        }
        if(block.timestamp >= deployDate + 2 days){
            maxSupply = 2;
        }
        if(block.timestamp >= deployDate + 3 days){
            maxSupply = 3;
        }
        if(block.timestamp >= deployDate + 4 days){
            maxSupply = 4;
        }
        if(block.timestamp >= deployDate + 5 days){
            maxSupply = 5;
        }

        require(totalSupply() < maxSupply, "max supply reached for now");
        ... (rest of safeMint code)...
}

I will probably move to safemath to prevent overflow errors and i recommend you do the same but I left it as normal signs to keep understanding simple. If you want to learn more about time in solidity this article was super helpful.
https://soliditytips.com/articles/solidity-dates-time-operations/

if you want month intervals just do deployDate + 4 weeks or however many days are within each month you are releasing

Hope this helped :slight_smile:

Hi Zergucci,

Thank you for the response. I have a question regarding monthly payements (fees, rents, etc).
You recommend using 4 weeks... but what if I'm trying to have exact monthly installments?

I saw OpenZeppelin is implementing a Datetime utils, which is great (https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3255), but I wonder if it's worth the cost to calculate the different month to seconds periods, which vary greatly.

By the way, I don't understand how Solidity can infer seconds from year since there are years that are longer than others...

Thanks in advance,

Antoine