The contracts wizard derives the following code for ERC721 and when I check the Votes
option:
contract MyToken is ERC721, EIP712, ERC721Votes {
constructor() ERC721("MyToken", "MTK") EIP712("MyToken", "1") {}
// The following functions are overrides required by Solidity.
function _afterTokenTransfer(address from, address to, uint256 tokenId)
internal
override(ERC721, ERC721Votes)
{
super._afterTokenTransfer(from, to, tokenId);
}
}
Why does the contract inherit from both ERC721
AND ERC721Votes
? Since ERC721Votes
in turn inherits from ERC721
? Doesn't this essentially inherit from ERC721.sol
twice? Wouldn't we be just fine if I just inherited from ERC721Votes
, receiving the votes functionality on top of the vanilla ERC721 functionality? I removed the inheritance from ERC721
and as far as I can tell, it works just fine.
Second question: As I understand, the _afterTokenTransfer
requires an override because two parent classes of MyContract
, the ERC721 and ERC721Votes contract both implement _afterTokenTransfer
. In order to resolve the confusion of which to call, we have to implement it again in the current contract. But since there is multiple inheritance, what contract does the super
keyword refer to??