1

The openzeppelin ERC721.sol file contains the following code:

    constructor (string memory name, string memory symbol) public {
    _name = name;
    _symbol = symbol;

    _registerInterface(_INTERFACE_ID_ERC721);
    _registerInterface(_INTERFACE_ID_ERC721_METADATA);
    _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
}

I have imported this file and declared a constructor as follows in my Smart Contract:

 import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

 contract MyNFT is ERC721 {
    constructor() ERC721("MyNFT", "MNFT") public {
    }
 }

Will the constructor in my Smart Contract call the constructor found in the ERC721.sol openzeppelin file, and thus register the interfaces found in the openzeppelin file, or do I need to explicitly include the _registerInterface lines of the file in my own Smart Contract?

Thank you. J

1 Answer 1

1

Register the interfaces found in the OpenZeppelin file, or do I need to explicitly include the _registerInterface lines of the file in my own Smart Contract

Calling the parent does this for you. You do not need to do it yourself. Both parent and child code live in the same address. Only if you use Solidity libraries your life gets complicated.

0

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.