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);
}
}
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With