5

How does etherscan know that a particular transaction is an ERC20 token transfer? If you look here: https://rinkeby.etherscan.io/tx/0xa8e4aa4f533e03bd8298f393d50d4ca41dba3368493c481e386d11389008353d etherscan knows that account A is transfering account B 200 tokens. IM quite familiar with quering ethereum using JSON RPC, so IM wondering if that info is there somewhere.

Thanks

  • The signatures of the functions/events from ERC20 are known from the standard and can be decoded from transaction data or transaction receipt (for events). – ivicaa Feb 23 '18 at 19:46
4

It knows because:

  1. The contracts implement the standard ERC20 interface
  2. The address is calling the transfer(address to, uint amount) function on the ERC20 contract
  3. The contract logs the standard ERC20 event Transfer(address to, uint amount)
  • 1
    thanks, do you know how can I capture such event using JSON RPC requests? Im interested in past events associated with an ICO – Diego Feb 26 '18 at 15:04
3

At a minimum, Etherscan is noting that the transaction had an accompanying event with the signature Transfer(address,uint256). I'm not sure if they also look for other ERC20 compatibility in the contract (e.g. a name, symbol, and totalSupply).

  • thanks, same question as above, do you know how can I capture such event using JSON RPC requests? Im interested in past events associated with an ICO – Diego Feb 26 '18 at 15:04
  • 1
    What did you try so far and where did you get stuck? – smarx Feb 26 '18 at 16:08
  • I can get the balance (#of token) of an account using eth_call (and concatenating 0x70a08231 (the sha3 of the functionu wrote above) with the account address on the "data" field and the contract on the "to" field. That works like a charm but in order to get something meaningfull I'd need to know to which accounts there were transfers; I could get a list of accounts from the transactions but that would require me to parse the blocks by block...which may be doable but Im just wondering if there is an easy way. Ive heard about the events but I'm not sure if they would help me in this case. Thanks – Diego Feb 26 '18 at 22:00
  • Yes, the events would help. Look at eth_getLogs. – smarx Feb 26 '18 at 22:03
  • do you have an example I can base myself on? Im not sure how to interact with the eth_getLogs and cant find good eamples online. Thanks – Diego Feb 27 '18 at 19:59

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.