thirdweb

NFT Collection Limited to 1 Mint

An NFT Collection where MintTo can only be called once per address

This mapping was added to track mints to a wallet

/// @dev Address => has minted => whether the address has minted a token. mapping(address => bool) public hasMinted;

_mintTo checks if this address has been mintedTo before and if not, allows the mint & then adds to the hasMinted mapping

/// @dev Mints an NFT to `to` function _mintTo(address _to, string calldata _uri) internal returns (uint256 tokenIdToMint) { tokenIdToMint = nextTokenIdToMint; nextTokenIdToMint += 1; require(bytes(_uri).length > 0, "empty uri."); // require that the user has not minted before require(!hasMinted[_to], "user has minted before"); _setTokenURI(tokenIdToMint, _uri); _safeMint(_to, tokenIdToMint); // Mark that the user has minted hasMinted[_to] = true; emit TokensMinted(_to, tokenIdToMint, _uri); }

This is vulnerable to sybil attacks.

1.0.1 Release Notes


Allow admins to set a max number of NFTs that can be minted


DEFAULT_ADMIN_ROLE

(DEFAULT_ADMIN_ROLE)

view

Published by

View all contracts

Details

  • Publish Date

    Feb 18, 2024

  • Licenses

    MIT, Apache-2.0

  • Learn more about Publish
    NFT Collection Limited to 1 Mint | Published Smart Contract