I want to fetch certain transaction logs from a local ethereum node. For that, I need to identify how to differentiate between ERC 20 and ERC 721 transaction receipts. From what I saw on Etherscan, i couldn't find any differentiating method as both the receipts look similar. The link of an ERC 20 transaction receipt is here https://etherscan.io/tx/0xbad497f6d96dd111c221ce41355cbb9ac912a6c0953ccb94113ba8232ab95e0a and ERC 721 transaction receipt is https://etherscan.io/tx/0x1ae8ba8417d6603e4f0b930b768814883af2d0ee091bc78145e871171768710e.


Here is the Transfer event prototype on each standard:

  • ERC20: event Transfer(address, address indexed _to, uint256 _value)
  • ERC721: event Transfer(address, address indexed _to, uint256 indexed _tokenId)

These two signatures are indeed the same when you hash them for the purpose of locating Transfer events in the ledger using (for example):

receipt.topics[0] == Web3.utils.keccak256("Transfer(address,address,uint256)")

However, note that each one of them has a different number of indexed parameters.

Therefore, you can determine if a transfer receipt is ERC20 or ERC721 as follows:

  • ERC20: receipt.topics.length == 1
  • ERC721: receipt.topics.length == 2

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.