If I have only an Ethereum address and only a locally running node (using a third party such as EtherScan or Alethio is cheating), is there any way to tell if that address is an ERC20 or an ERC721 token? I thought of querying the 'name' and/or 'symbol' function, and that works (non-tokens never return a name or symbol), but it doesn't work perfectly. Some ERC20 or ERC721 tokens don't return a name or a symbol, but they are (albeit noncompliant) tokens. Thanks.

  • Well, I suppose that strictly speaking, you can simply refer to any non-compliant token, as if it's not a token... That should solve one side of the problem. The other side of the problem is if you have, for example, a fully compliant ERC20 token which also implements (for whatever reason) all the ERC721 functions which you're relying on. – goodvibration Mar 1 '20 at 16:44
  • I meant to ask if one could distinguish between contracts that are ERC20 (or ERC721) by looking at the data -- programatically. Not really asking about what's 'permissable' to call something a token -- I'm asking about using the data (and only the data) from the node to determine same. – Thomas Jay Rush Mar 2 '20 at 17:18
  • Thought you wanted to distinguish between ERC20s and ERC721s. – goodvibration Mar 2 '20 at 17:21
  • Anyway, programatically - more or less. Either download the bytecode and check that the hash of each standard function is present. Or just call every standard function and make sure that no exception is thrown (for non-constant functions, use call instead of send of course). – goodvibration Mar 2 '20 at 17:23
  • That's what I feared. When you say "check that the hash of standard functions exist" is it enough to just search for the signatures of transfer, tranferFrom, etc. in the byte code? ``` If (code contains sig1 and sig2 and sig3 and sig4....) ``` – Thomas Jay Rush Mar 4 '20 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.