Skip to content

Instantly share code, notes, and snippets.

@sajclarke
Created October 8, 2018 14:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sajclarke/9bc0a0670d43117f16d3421401e97144 to your computer and use it in GitHub Desktop.
Save sajclarke/9bc0a0670d43117f16d3421401e97144 to your computer and use it in GitHub Desktop.
web3 v1.0.0 - how to get past events
const DEPLOYED_ADDRESS
const CONTRACT_EVENT
try {
const web3 = await this.getWeb3()
const accounts = await web3.eth.getAccounts()
const tickerRegInstance = new web3.eth.Contract(TickerRegistry.abi, DEPLOYED_ADDRESS)
console.log(tickerRegInstance)
tickerRegInstance.methods.polyToken().call({ from: accounts[0] }).then((result) => {
console.log(result);
});
tickerRegInstance.getPastEvents(CONTRACT_EVENT, { filter: { _owner: accounts[0] }, fromBlock: 0, toBlock: "latest" }, function (
error,
events
) {
if (error) {
console.log(error);
} else {
//Return events
console.log(events);
}
});
} catch (error) {
console.log('error', error)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment