0

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?

0

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.

2
  • 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 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/… – William Entriken May 10 at 19:18

Your Answer

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

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