1

In this ERC721 implementation by 0xcert there is this _mint function:

function _mint(address _to, uint256 _tokenId) internal override virtual {
    super._mint(_to, _tokenId);
    tokens.push(_tokenId);
    idToIndex[_tokenId] = tokens.length - 1;
}

I need to understand the use of super._mint here, what is the logic behind this?

2 Answers 2

1

Taken from the Solidity 0.6.2 docs:

super: the contract one level higher in the inheritance hierarchy

That means super._mint(_to, _tokenId); in your code is actually pointing to method _mint() in contract NFToken which is located in file nf-token.sol. At the top of your smart contract you are importing that file like this import "./nf-token.sol";.

1

The contract that you've linked in your question starts with:

contract NFTokenEnumerable is
  NFToken,
  ERC721Enumerable
{

Which means that super._mint(_to, _tokenId) calls function mint of either contract NFToken or contract ERC721Enumerable. A short search in that GitHub repo reveals that this function is in contract NFToken.

It's an internal function-call of course, because NFTokenEnumerable IS a (rather than HAS a) NFToken, i.e., no jump to another contract's code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.