1

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); 
myCoin.transferFrom();

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

  • 1
    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. – smarx May 15 '18 at 0:54
  • That seems to work, thanks. What is the difference between an import and inheriting? – ocon404 May 15 '18 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). – smarx May 15 '18 at 18:47
0

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.

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.