Step into the Mint NFT experience.
Guide
Contract Summary
The AllowlistNFT.sol
smart contract is an extension of an ERC721 smart contract. The ERC721A implementation is an extension of the ERC721 specification, and is optimized for gas savings and batch operations.
publicMint
Explanation
The publicMint
function allows anyone to mint an NFT from the contract so long as the mint is live and the allowlist time period has elapsed.
...
The above conditions correspond to the live
and allowlistClose
variables, respectively. These values are stored as state variables in the contract, and are set in the constructor
.
The modifier whenLive
is attached to the publicMint
function, which checks the value of the live
state variable to determine whether to revert the transaction or not.
...
The owner of the contract can call the toggleLive function to flip the boolean value of live, thus enabling and disabling minting NFTs.
Assuming live
is set to true, the publicMint
function will then ensure that the timestamp of the block being mined is greater than the timestamp stored in allowlistClose
. Otherwise, the transaction will revert.
...
If the above check succeeds, then the requested number of NFTs to mint will be calculated and added to the total number of NFTs the caller (msg.sender
) has minted previously. If this new total exceeds the maximum allowed NFTs to mint per-person or globally, then the transaction will revert.
...
Then, the function will check the supplied amount of ETH (msg.value
) to ensure that enough ETH has been provided to mint the requested number of NFTs at the current price.
...
Assuming all these checks succeed, publicMint
will then mint the specified amount of NFTs to the caller address.
...