Solidity API

X2EarnCreator

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.

PAUSER_ROLE

bytes32 PAUSER_ROLE

MINTER_ROLE

bytes32 MINTER_ROLE

BURNER_ROLE

bytes32 BURNER_ROLE

UPGRADER_ROLE

bytes32 UPGRADER_ROLE

TransfersDisabled

error TransfersDisabled()

Error thrown when a transfer attempt is made, as transfers are disabled

AlreadyOwnsNFT

error AlreadyOwnsNFT(address owner)

Error thrown when a user already owns an NFT

X2EarnCreatorUnauthorizedUser

error X2EarnCreatorUnauthorizedUser(address user)

Error thrown when a user is not authorized to perform an action

X2EarnCreatorStorage

Storage structure for X2EarnCreator

struct X2EarnCreatorStorage {
  uint256 nextTokenId;
  string baseURI;
}

constructor

constructor() public

initialize

function initialize(string baseURI, address defaultAdmin) public

Initializes the contract with role-based access control

Parameters

Name Type Description
baseURI string The base URI for the NFT metadata
defaultAdmin address Address to be assigned the default admin role

onlyRoleOrAdmin

modifier onlyRoleOrAdmin(bytes32 role)

Modifier to check if the user has the required role or is the DEFAULT_ADMIN_ROLE

Parameters

Name Type Description
role bytes32 - the role to check

pause

function pause() public

Pauses all token transfers and minting functions

Only callable by accounts with the PAUSER_ROLE or the DEFAULT_ADMIN_ROLE

unpause

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

burn

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

Parameters

Name Type Description
tokenId uint256 ID of the token to burn

safeMint

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.

Parameters

Name Type Description
to address Address that will receive the new token

tokenURI

function tokenURI(uint256 tokenId) public view returns (string)

Ensures the token ID is owned, then returns the base URI as the token URI

Parameters

Name Type Description
tokenId uint256 The ID of the token to retrieve the URI for

Return Values

Name Type Description
[0] string The metadata URI for the specified token ID

baseURI

function baseURI() public view returns (string)

Retrieves the base URI for the NFT metadata

Return Values

Name Type Description
[0] string The base URI for the NFT metadata

version

function version() public pure returns (string)

Retieves the version of the contract

transferFrom

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

safeTransferFrom

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

approve

function approve(address, uint256) public pure

Prevents approvals by reverting any call to approve

Override to disable approval functionality

setApprovalForAll

function setApprovalForAll(address, bool) public pure

Prevents setting approval for all by reverting any call to setApprovalForAll

Override to disable approval functionality

setBaseURI

function setBaseURI(string newBaseURI) public

Sets the base URI for the NFT metadata

Only callable by accounts with the DEFAULT_ADMIN_ROLE

Parameters

Name Type Description
newBaseURI string The new base URI for the NFT metadata

_baseURI

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.

_authorizeUpgrade

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)

supportsInterface

function supportsInterface(bytes4 interfaceId) public view returns (bool)

_increaseBalance

function _increaseBalance(address account, uint128 value) internal