For I am not good at coding,so coud anyone tell me directly,how could set the maximum amount of a ERC721 token.Better give me a code example,I know it’s presumptuous and looks lazy. ,But it does save me a lot of time.
THX A LOT!
To implement you should do the following:
- Have a state variable for the cap.
- Set the cap in the constructor.
- Have a getter so that the cap can be read.
- In the mint function of your ERC721, check if the total number minted (you will need a count of this total supply) is less than the cap before minting.
ERC20Capped.sol shows how to do this for ERC20
For a counter you can use Counters
and do you have one for ERC721 smart contract ?
Just take the exact same
cap logic from his example and place it in an ERC721 contract. There’s nothing special which binds that code to ERC20 only.
It should work fine.
nice and thanks a lot