How can I implement code that returns whether a token is in the ERC721 or ERC1155 standard, knowing both the contract address and the tokenId? What I tried is that I call a function that exists only on ERC1155 standard and if it fails then it's obviously an ERC721 token. But this is probably not the best solution. Any tips?

2 Answers 2


Please study ERC-165 and see the interface detection discussed in both ERC-721 and ERC-1155.

0xcert and OpenZeppelin both include implementations so I would not want to paste everything in here.

  • Looked it up, probably that's what I need ,although I don't really understand how to use it. As I understand, I need the ERC165Checker library's _supportsInterface function which tells me if a specific contract at address has a specific interface. But how can I use this function outside of solidity in js with web3?
    – warren1235
    May 9, 2021 at 6:59
  • Please see here eips.ethereum.org/EIPS/…. And then as how to implement that using web3js, please see web3js.readthedocs.io/en/v1.3.4/… May 10, 2021 at 19:18

I have an implementation which doesn't rely on erc-165, but we get the code and check if certain function signature exists, check the implementation here: https://github.com/botfi-app/token-standard-detector

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.