3

Hi I am a bit confused here. The official EIP documentation states that

event Transfer(address indexed _from, address indexed _to, uint256 _value)

is how the Transfer event should look like. If I am trying to listen to this event in web3, I will be looking for the keys that are mentioned in this interface namely _from, _to and _value.

I checked out a few of the top ERC20 contracts and they all have different key names in the event. From skipping the _ to completely changing value to amount. If I am listening to transfer events from multiple tokens, is there a way I can generalize this. Can I get value at a position by being key-name agnostic?

  • 1
    So your question is about event-listening/filtering, not about ERC20. You probably want to fix the title in order to reflect this fact. – goodvibration Jul 2 at 5:20
2

The order of arguments is always the same, though their names may vary. Also, you are supplying your own ABI file, so you most likely use argument names given in that ABI file. The EVM/Solidity wire protocol hashes only argument types, not their names, so the actual name is irrelevant in the raw blockchain data.

A lot of tokens were deployed before ERC-20 standard was anywhere near the final form, so there are quirks with legacy tokens.

The "hard" signature of Transfer event is 32-bit word, bytes 0-4 of:

 keccak("Transfer(address,address,uint256)")

The payload is 3x 256-bit words, as almost every value in EVM is 256-bit:

- address 1 
- address 2
- amount
  • I get that the names are not relevant during execution. But when the event is emitted and I am listening to it, once I receive the event and try to process it, I need to check the specific variables in the event. If it is one token I can check the contract and know the exact names. But I was looking for a generalized way to listen to transfer events. – Sanjay S B Jul 2 at 9:34
  • 1
    Those events argument names come from your local ABI file, not deployed ERC-20 contract code. – Mikko Ohtamaa Jul 2 at 9:51
  • Updated the answer for more details – Mikko Ohtamaa Jul 2 at 9:56

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.