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.

Sundeep Kumar
  • 147
  • 2
  • 10

3 Answers3

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!

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

eth
  • 85,679
  • 53
  • 285
  • 406
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.