Git Source

Inherits: ERC721, AccessControl, IProtocolToken, IApplicationEvents, IZeroAddressError, ReentrancyGuard, ERC721Burnable, ERC721Enumerable

Author: @ShaneDuncan602, @oscarsernarosero, @TJ-Everett, @Palmerg4

This is an example implementation that App Devs should use.

During deployment _tokenName _tokenSymbol _tokenAdmin are set in constructor

State Variables

_tokenIdCounter

Counters.Counter internal _tokenIdCounter;

TOKEN_ADMIN_ROLE

bytes32 constant TOKEN_ADMIN_ROLE = keccak256("TOKEN_ADMIN_ROLE");

handlerAddress

address private handlerAddress;

baseUri

Base Contract URI

string public baseUri;

Functions

constructor

Constructor sets params

constructor(string memory _name, string memory _symbol, address _tokenAdmin, string memory _baseUri)
    ERC721(_name, _symbol);

Parameters

NameTypeDescription
_namestringName of the token
_symbolstringSymbol of the token
_tokenAdminaddressToken Admin address
_baseUristring

_baseURI

Function to return baseUri for contract

function _baseURI() internal view override returns (string memory);

Returns

NameTypeDescription
<none>stringbaseUri URI link to NFT metadata

setBaseURI

this is called in the constructor and can be called to update URI metadata pointer

Function to set URI for contract.

function setBaseURI(string memory _baseUri) public virtual onlyRole(TOKEN_ADMIN_ROLE);

Parameters

NameTypeDescription
_baseUristringURI to the metadata file(s) for the contract

safeMint

Add appAdministratorOnly modifier to restrict minting privilages Function is payable for child contracts to override with priced mint function.

Function mints new a new token to caller with tokenId incremented by 1 from previous minted token.

function safeMint(address to) public payable virtual onlyRole(TOKEN_ADMIN_ROLE);

Parameters

NameTypeDescription
toaddressAddress of recipient

_beforeTokenTransfer

Function called before any token transfers to confirm transfer is within rules of the protocol

function _beforeTokenTransfer(address from, address to, uint256 tokenId, uint256 batchSize)
    internal
    override(ERC721, ERC721Enumerable)
    nonReentrant;

Parameters

NameTypeDescription
fromaddresssender address
toaddressrecipient address
tokenIduint256Id of token to be transferred
batchSizeuint256the amount of NFTs to mint in batch. If a value greater than 1 is given, tokenId will represent the first id to start the batch.

supportsInterface

Returns true if this contract implements the interface defined by interfaceId. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.

function supportsInterface(bytes4 interfaceId)
    public
    view
    override(AccessControl, ERC721, ERC721Enumerable)
    returns (bool);

getHandlerAddress

This function returns the handler address

function getHandlerAddress() external view override returns (address);

Returns

NameTypeDescription
<none>addresshandlerAddress

connectHandlerToToken

This function does not check for zero address. Zero address is a valid address for this function’s purpose.

Function to connect Token to previously deployed Handler contract

function connectHandlerToToken(address _deployedHandlerAddress) external override onlyRole(TOKEN_ADMIN_ROLE);

Parameters

NameTypeDescription
_deployedHandlerAddressaddressaddress of the currently deployed Handler Address

withdraw

Function to withdraw Ether sent to contract

AppAdministratorOnly modifier uses appManagerAddress. Only Addresses asigned as AppAdministrator can call function.

function withdraw() public payable virtual onlyRole(TOKEN_ADMIN_ROLE);