Is it possible to have a contract that both generates and manages its own NFT according to the ERC721 Standard, and is able to make calls to outside ERC20 contracts? My contract currently inherits the ERC20 interface or contract, so that it can calls an instance of ERC20

someCoin = ERCInterface(xxxxxx); 

However, the approve() and transferFrom() functions have the exact same number and types of arguments in both standards so the ERC721 functions get overwritten. Does anyone know of a workaround? Alternatively, can someone provide an example of how a direct contract call can be written? Thanks

  • 2
    Why are you inheriting the ERC20 interface? It sounds like you need to call out to external contracts that follow that interface. No need to inherit it for that, just import the interface, cast the external address, and make the call.
    – user19510
    May 15, 2018 at 0:54
  • That seems to work, thanks. What is the difference between an import and inheriting?
    – ocon404
    May 15, 2018 at 18:27
  • It's hard to answer that because the two are unrelated. Importing a file is like copy/pasting the code from that file. Inheritance is a concept from object-oriented programming where a new class/contract is based on the implementation of another one: en.wikipedia.org/wiki/Inheritance_(object-oriented_programming).
    – user19510
    May 15, 2018 at 18:47

2 Answers 2


One contract cannot simultaneously implement ERC-20 and ERC-721. You must design your system so that those are separate contracts (deployed at separate addresses).

Yes, you can have a ERC-721 contract make calls to an ERC-20 contracts. There is nothing that makes that a problem.

  • 1
    Actually, single contract may simultaneously implement both: ERC-20 and ERC-721. The only common method signature is balanceOf(address) and its return type is the same for both ERCs. Jun 23, 2019 at 22:02

You don't have to inherit an interface in order to call its methods:

interface Foo {
  function doFoo () external;

contract Bar {
  function bar (Foo foo) public {
    foo.doFoo ();

You need to inherit an interface only when you want you contract to implement this interface by itself:

contract MyFoo is Foo {
  function doFoo () public {
    // Do something useful here

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.