0
// openzeppelin v5
contract ERC721Full is ERC721, ERC721Enumerable, ERC721Metadata {
    constructor (string memory name, string memory symbol) public ERC721Metadata(name, symbol) {
        // solhint-disable-previous-line no-empty-blocks
    }
}


contract Test is ERC721Full {   
   // ctor...

  function createToken(...) public {
    _mint(msg.sender, id);
  }
}

Basically, I have a contract that inherits openzeppelin's ERC721Full contract.

My question is, when _mint is called in createToken, why does it call _mint in ERC721Enumerable instead of _mint in ERC721?

Is it because ERC721Enumerable is inherited in ERC721Full next to ERC721 in the sequence?

ex: ERC721 -> ERC721Enumerable.

2

I got the answer myself. It's because solidity uses c3 linearlization.

Another simplifying way to explain this is that when a function is called that is defined multiple times in different contracts, the given bases are searched from right to left (left to right in Python)

So I was kinda right in that it searches from right to left.

  • If you have questions on using OpenZeppelin you can ask in the Community Forum: forum.openzeppelin.com Disclosure: I am the Community Manager at OpenZeppelin – abcoathup Aug 11 at 23:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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