If I import the IERC721 Interfaces in my Smart Contract, do I need to define the signature of all the functions found in the said Interfaces in order for them to be available, or the simple import statement is sufficient?
Thank you J
If I import the IERC721 Interfaces in my Smart Contract, do I need to define the signature of all the functions found in the said Interfaces in order for them to be available, or the simple import statement is sufficient?
Thank you J
Importing it only brings it to context for solc to resolve references to it, for example you can use it to make calls from a contract that handles ERC721 without the contract being one nor implementing its functions.
If you’re inheriting from it (Contract is IERC721
), then you have to either implement all of the functions in the interface or to mark the contract as abstract.
Thank you for your answer martriay!
Sorry martriay, I am still a little confused regarding Interfaces. When you mention “implement all of the functions in the interface”, do you mean actually defining their respective body? My intent, based on my understanding of interfaces, was to declare an Interface (with the Interface keyword), and include in the interface the signature of all the functions found in the interface in question as the following:
interface IERC721 {
function balanceOf(address owner) external view returns (uint256 balance);
// (list of all events and functions...)
.
.
.
}
Is this how it should be done? Since I am already importing and inheriting the interface, shouldn’t all the functions from the interface be immediately available without having to enumerate them?
Thank you again. JF
Hi @JF0001,
If you are trying to create your own ERC721, then you can inherit from IERC721 and implement all the functions or extend from OpenZeppelin Contracts ERC721 implementation.
See the documentation for details:
If you are wanting to interact with an ERC721 from your contract, then you can create a variable of type IERC721 and call the functions in IERC721.
Thank you @abcoathup.