0

1.)Is it correct to say..... if i import ERC721.sol into my contract then all the ERC721.sol functions are accessible even if i don't list all the functions in the contract? Meaning... i don't necessarily have to list/write out each function in my contract but users can still use all of them (ERC721 functions) just as long as i import it into my contract?

2.)By contrast, if i use/import an interface like IERC721 into my contract than I "MUST" display/list "ALL" the functions in my contract? I can't just use a few of them, i have to use ALL of them right?

3.)Why would one choose to use the interface (IERC721) when designing his contract, versus the actual standard contract (ERC721)? Is it just because its easier for other users to interact with it? Is that the main benefit?

1 Answer 1

0

Interfaces are typically used to interface with external contracts because they allow you to do so without inheriting the entire contract. Ethereum has a contract size limit that isn't difficult to hit, and this is mitigated by using interfaces.

So, if you wanted to query SomeContract from your contract you could run ISomeContract(0x<SomeContract_address>).someFunction

IERC721 is used to interface with ERC-721 contracts

1
  • Thanks for the response. So if interfaces are best for interacting with external contracts than I probably don't want to "inherit" an interface. Like if i said... "MyContract is IERC721"... that wouln't make much sense right? In this particular case i am looking for my contract to extend its functionality... so I should probably do... "MyContract is ERC721" ? Is that correct? I ask, becaseu i am doing this tutorial and in it they have us doing.... MyContract is IERC721. That seems odd to me to inherit an interface right? Or am i wrong and this is appropriate?
    – Blockpain
    Commented Aug 5, 2022 at 18:00

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.