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.
Asked
Active
Viewed 3,184 times
2
-
1Does this answer your question? How to check if a contract has a method? – Paul Razvan Berg Apr 13 '22 at 16:36
-
Also see this: Why use the ERC165 standard? – Paul Razvan Berg Apr 13 '22 at 16:36
3 Answers
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!
Gonçalo Velosa
- 11
- 1
1
A detailed solution to your answer is given Stack Overflow. Please do have a look:
eth
- 85,679
- 53
- 285
- 406
sachin singh jagawat
- 11
- 2
0
Answer can be divided into two cases:
- address supports ERC165 (implements
supportsInterface), but it is not ERC721; - address does not support ERC165 (no
supportsInterfaceimplementation). 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.
Ivan Solomichev CG
- 29
- 5