0

Aim: To get the name, symbol and tokenURI of another ERC721 contract from my Solidity contract. The goal is to create a one-click clone of a contract for a microprotocol.

What I've done thus far: IERC721 getTokenDetails = IERC721(_targetNFT); - however when I call getTokenDetails.name() I get Member "name" not found or not visible after argument-dependent lookup in contract IERC721. - which is expected since ./IERC721.sol on OpenZeppelin does not have name() or symbol()

Question: How do I work around this problem?

1 Answer 1

1

If you are sure the target contract contains those functions, you can use the metadata interface: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/extensions/IERC721Metadata.sol

Whenever you know that a contract has some function you want to access, you can either use an existing interface or simply write your own. The interface can contain only the functions you are interested in.

2
  • thank you Lauri, this is excellent. Should I call IERC721Metadata(_contractAddress) for this?
    – abhinavmir
    Commented Apr 7, 2022 at 14:45
  • Yes. Just like using any other interface. Commented Apr 7, 2022 at 15:53

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.