Contract for minting and managing NFTs for X2Earn creators of VeBetterDAO.
This contract extends ERC721 Non-Fungible Token Standard basic implementation with upgradeable pattern, enumerable, pausable, and access control functionalities.
bytes32 PAUSER_ROLE
bytes32 MINTER_ROLE
bytes32 BURNER_ROLE
bytes32 UPGRADER_ROLE
error TransfersDisabled()
Error thrown when a transfer attempt is made, as transfers are disabled
error AlreadyOwnsNFT(address owner)
Error thrown when a user already owns an NFT
error X2EarnCreatorUnauthorizedUser(address user)
Error thrown when a user is not authorized to perform an action
Storage structure for X2EarnCreator
struct X2EarnCreatorStorage {
uint256 nextTokenId;
string baseURI;
}
constructor() public
function initialize(string baseURI, address defaultAdmin) public
Initializes the contract with role-based access control
Name | Type | Description |
---|---|---|
baseURI | string | The base URI for the NFT metadata |
defaultAdmin | address | Address to be assigned the default admin role |
modifier onlyRoleOrAdmin(bytes32 role)
Modifier to check if the user has the required role or is the DEFAULT_ADMIN_ROLE
Name | Type | Description |
---|---|---|
role | bytes32 | - the role to check |
function pause() public
Pauses all token transfers and minting functions
Only callable by accounts with the PAUSER_ROLE or the DEFAULT_ADMIN_ROLE
function unpause() public
Unpauses the contract to resume token transfers and minting
Only callable by accounts with the PAUSER_ROLE or the DEFAULT_ADMIN_ROLE
function burn(uint256 tokenId) public
Burns a specific token, removing it from circulation
Only callable by accounts with the BURNER_ROLE or the DEFAULT_ADMIN_ROLE
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the token to burn |
function safeMint(address to) public
Mints a new token to a specified address
Only callable by accounts with the MINTER_ROLE or the DEFAULT_ADMIN_ROLE. Ensures the address does not already own a token.
Name | Type | Description |
---|---|---|
to | address | Address that will receive the new token |
function tokenURI(uint256 tokenId) public view returns (string)
Ensures the token ID is owned, then returns the base URI as the token URI
Name | Type | Description |
---|---|---|
tokenId | uint256 | The ID of the token to retrieve the URI for |
Name | Type | Description |
---|---|---|
[0] | string | The metadata URI for the specified token ID |
function baseURI() public view returns (string)
Retrieves the base URI for the NFT metadata
Name | Type | Description |
---|---|---|
[0] | string | The base URI for the NFT metadata |
function version() public pure returns (string)
Retieves the version of the contract
function transferFrom(address, address, uint256) public pure
Prevents token transfers by reverting any call to transferFrom
Override to disable token transfers, making tokens non-transferable
function safeTransferFrom(address, address, uint256, bytes) public pure
Prevents safe token transfers by reverting any call to safeTransferFrom
Override to disable safe token transfers, making tokens non-transferable
function approve(address, uint256) public pure
Prevents approvals by reverting any call to approve
Override to disable approval functionality
function setApprovalForAll(address, bool) public pure
Prevents setting approval for all by reverting any call to setApprovalForAll
Override to disable approval functionality
function setBaseURI(string newBaseURI) public
Sets the base URI for the NFT metadata
Only callable by accounts with the DEFAULT_ADMIN_ROLE
Name | Type | Description |
---|---|---|
newBaseURI | string | The new base URI for the NFT metadata |
function _baseURI() internal view returns (string)
Returns the base URI used for all token metadata URIs in the contract
This function retrieves the base URI from the contract’s storage.
function _authorizeUpgrade(address newImplementation) internal
_Function that should revert when msg.sender
is not
authorized to upgrade the contract. Called by {upgradeToAndCall}.
Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
function _authorizeUpgrade(address) internal onlyOwner {}
```_
### _update
```solidity
function _update(address to, uint256 tokenId, address auth) internal returns (address)
function supportsInterface(bytes4 interfaceId) public view returns (bool)
function _increaseBalance(address account, uint128 value) internal