2

I would like to know if there is any method of identifying if an address is erc721 or 1155 without calling the differentiating functions on both.

2

3 Answers 3

1

According to the IEP-165 you can, I had a similar issue/question this article helped me.

Solidity get interface id and ERC165 by Nhan Cao

Hope this helps you out as well!

0
1

A detailed solution to your answer is given Stack Overflow. Please do have a look:

https://stackoverflow.com/questions/69706835/how-to-check-if-the-token-on-opensea-is-erc721-or-erc1155-using-node-js

0

Answer can be divided into two cases:

  1. address supports ERC165 (implements supportsInterface), but it is not ERC721;
  2. address does not support ERC165 (no supportsInterface implementation). As an example, it can be ERC20, any Smart Contract, EOA, etc.

First case: nftAddress.supportsInterface(type(IERC721).interfaceId); returns false. Thus your require or if - else handles it normally.

Second case: as supportsInterface is not implemented at all, transaction fails without reason.

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.