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)
console.log(result);
});
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.
source