Created
October 8, 2018 14:44
-
-
Save sajclarke/9bc0a0670d43117f16d3421401e97144 to your computer and use it in GitHub Desktop.
web3 v1.0.0 - how to get past events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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