Look at this.

We are able to see tx, from, to, value etc... How is etherscan achieving this? I badly need this kind of functionality in my app. How can I list token transfers for a ERC20 contract?

Note, do not suggest me etherscan api etc, I need to this with web3js or other ethereum approaches.

1 Answer 1


Contract Events:

The ERC20 specification defines events such as Transfer that will be "logged" when a token is transferred from one address to another; these events contain quite a lot of information.

The Web3 JS API allows you to either look back through past blocks for Events that were logged or to listen for events as new blocks are mined.

Look through a range of blocks

// watch for an event with {some: 'args'}
var myEvent = myContractInstance.MyEvent({some: 'args'}, {fromBlock: 0, toBlock: 'latest'});
myEvent.watch(function(error, result){

Watch for new events

var event = myContractInstance.MyEvent({valueA: 23} [, additionalFilterObject])

// watch for changes
event.watch(function(error, result){
  if (!error)

The details that can be found in the returned event object(s)

Object - An event object as follows:

**address**: String, 32 Bytes - address from which this log originated.
**args**: Object - The arguments coming from the event.
**blockHash**: String, 32 Bytes - hash of the block where this log was in. null when its pending.
**blockNumber**: Number - the block number where this log was in. null when its pending.
**logIndex**: Number - integer of the log index position in the block.
**event**: String - The event name.
**removed**: bool - indicate if the transaction this event was created from was removed from the blockchain (due to orphaned block) or never get to it (due to rejected transaction).
**transactionIndex**: Number - integer of the transactions index position log was created from.
**transactionHash**: String, 32 Bytes - hash of the transactions this log was created from.


  • 1
    Thank you, but when I get old logs, which is what I need, I am seeing transactionHash is 0x0000000000000000000000000000000000000000000000000000000000000000 for all logs, is this intended? All I want is that hash...
    – Lazy
    Oct 17, 2017 at 9:09

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.