August 2019
Intermediate to advanced
486 pages
13h 52m
English
The _mint() internal function is used to mint a new NFT at the given address. As the function is internal, it can only be used from inherited contracts to mint new tokens.
This function takes the following arguments:
Let's look at the _mint() function code:
function _mint(address to, uint256 tokenId) internal { require(to != address(0)); require(!_exists(tokenId)); _tokenOwner[tokenId] = to; _ownedTokensCount[to] = _ownedTokensCount[to].add(1); emit Transfer(address(0), to, tokenId);}
As you can see in the preceding code, the new tokenId is checked using the _exists() function, which ensures ...