Reputation: 295
I'm currently using the Truffle framework to check but all the documentation is around watching current events.
var meta = MetaCoin.deployed();
var events = meta.allEvents();
events.watch(function(error, result) {
if (error == null) {
console.log(result.args);
}
}
Upvotes: 4
Views: 2607
Reputation: 184
You need to specify the filter object to get all events from genesis (the crypto-people word for the first block) to now.
The following code should work:
MetaCoin.deployed().then(meta => {
const allEvents = meta.allEvents({
fromBlock: 0,
toBlock: 'latest'
});
allEvents.watch((err, res) => {
console.log(err, res);
});
});
That said: Be careful with general lookups like this. You can easily crash your JSONRPC endpoint.
Further reading: https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-allevents
Upvotes: 4