MyNft
is an ERC721 token contract implemented in Solidity. It inherits various features from OpenZeppelin's ERC721 implementation and its extensions, providing functionalities such as minting, pausing, burning, and voting.
The MyNft
ERC721 token contract is designed to provide a versatile and comprehensive implementation for non-fungible tokens (NFTs) with additional features. It incorporates functionalities such as pausing, burning, and tracking successful minting.
- ERC721: The core ERC721 token implementation, handling basic NFT functionality.
- ERC721Enumerable: Extends ERC721 to provide enumeration capabilities, allowing for efficient querying of token IDs.
- ERC721URIStorage: Extends ERC721 to store and retrieve token URIs associated with each token ID.
- ERC721Pausable: Extends ERC721 to add pausable functionality, allowing the contract owner to pause certain operations.
- Ownable: Provides basic access control, allowing the contract owner to execute certain functions.
- ERC721Burnable: Extends ERC721 to add burning functionality, allowing token owners to destroy their tokens.
- EIP712: A utility library providing EIP-712 signature verification functionalities.
- ERC721Votes: Extends ERC721 to enable voting mechanisms on token-related proposals.
ERC721 and Extensions ERC721: The core ERC721 contract provides basic functionalities for managing non-fungible tokens (NFTs), including ownership and transfer mechanisms.
ERC721Enumerable: This extension adds enumeration support, allowing efficient querying of token IDs.
ERC721URIStorage: Extends ERC721 to handle token URIs, providing a way to associate metadata with each token.
ERC721Pausable: This extension adds the ability to pause and unpause certain contract operations, giving the contract owner control over critical functions.
Access Control Ownable: The Ownable contract ensures that only the owner (deployer) of the contract has certain privileges, such as pausing and administrative actions. Token Burning ERC721Burnable: This extension allows token owners to burn (destroy) their tokens, removing them from circulation. Cryptographic Utilities EIP712: EIP-712 is a standard for typed structured data hashing and signing. This library provides utilities for handling EIP-712 signatures. Voting Mechanisms ERC721Votes: Extends ERC721 to enable voting mechanisms for proposals related to token governance. These dependencies make the MyNft contract a feature-rich ERC721 token, suitable for various NFT use cases with additional functionalities provided by OpenZeppelin libraries.
- _nextTokenId: Private variable to keep track of the next token ID to be minted.
- _mintedSuccessfully: Mapping to track addresses that have successfully minted tokens.
The constructor initializes the contract with the given initialOwner
address. It sets up configurations for ERC721, Ownable, and EIP712, providing a solid foundation for the contract's functionality.
pause():
Function to pause the contract, accessible only by the owner.unpause():
Function to unpause the contract, accessible only by the owner.
safeMint(address to, string memory uri):
Function to safely mint a new token for the specified address (to). It generates a new token ID, mints the token, sets its URI, and marks the address as successfully minted.
hasMintedSuccessfully(address account):
Function to check if a specific address has successfully minted a token.getAllMintedSuccessfully():
Function to get an array of addresses that have successfully minted tokens.
The contract includes overrides for functions like _update()
, _increaseBalance()
, tokenURI()
, and supportsInterface()
due to inheritance from various ERC721-related contracts. These overrides ensure compliance with ERC721 standards and seamlessly incorporate additional functionalities.
The MyNft
contract provides a comprehensive ERC721 implementation with additional features for pausing, burning, and tracking successful minting. Its design allows for flexibility and compatibility with various use cases in the NFT space, making it a versatile and robust token contract. The contract can be easily integrated into external systems, providing a powerful foundation for NFT-related applications.