The supportsInterfacesupportsInterface
shouldn't be used to check individual functions, each. Each interface should have a single interfaceID, which, as you can see in the ERC-721 implementation you posted, is constructed as follows:
But itsit's important to note that when you call supportsInterface
on 0x01ffc9a7
, you are testing to see if your contract supports the whole ERC165 standard. It just so happens that that there is only one function.
So you shouldn't be calling supportsInterface
on 0x8462151c
, this would checking be checking for an interface which only contained the function tokensOfOwner()
.
In steadInstead, you should be checking against the InterfaceIDinterfaceID of the whole ERC721 interface. If your contract supports the whole interface, then by definition it will support any of the functions contained therein.
The idea is that anyone can find the specification for the interface, and just check the interfaceIdinterfaceID of that interface against your contract.
Why thisThis is relevant to what you posted is because basic ERC721 does not implement any of the following:
If standards are developing and evolving over time, then ERC721 version 0.0.1 (a number I just made up) may have an interfaceIdinterfaceID of 0x9f40b779
(which is the value of InterfaceID_ERC721 in the contract you provided). However, version 0.0.2 may add, change, or remove a function, which would completely change the interfaceID to something else. So as long as you specify that your contract complies to ERC721 0.0.1, someone else can look up the interface, and check it against your contract.
So the very short answer to your question is, you shouldn't be checking supportsInterfacesupportsInterface
against a single function, but rather against the whole interface.