Hi there, can anyone please explain in plain terms why ERC165 is a thing. What does supportsInterface(bytes4 interfaceId) do exactly? Why is it necessary for ERC721 but not for ERC20? Thanks.

Mar 29, 2021, 8:16 AM
It's to enable safe transfers of tokens. It's to prevent scenarios, where use has ERC721 token and he wants to transfer it and he accidentally chooses wrong contract address where to send it. The ERC165 checks whether the receiving contract supports ERC721 or not - if it doesn't, the transfer is reverted, since the NFT would be stuck in the contract

Similar thing can be implemented in ERC20, but it's just not part of the standard there. My educated guess is that people figured out too late that transferring to unsupported contracts was a problem, and managed to fix it only for the ERC721
Mar 29, 2021, 8:23 AM
Thanks Lauri, this is very clear. My next question would be how and when to use it? It looks like it gets implemented in the ERC721 contract, but the function is supportsInterface which takes interfaceID as a parameter. This part got me really confused. Who gets to call this function then?
Mar 29, 2021, 8:45 AM
The interfaceID is basically string representation of the function signature. So it says that you need to support such function signature
Mar 29, 2021, 8:53 AM

© 2024 Draquery.com All rights reserved.