I'm trying to watch for an event on my front end but a bug is getting in the way.
Here's the JS watching for the event
import web3 from './web3';
export async function callEvent () {
await Contract.events.PracticeEvent().watch((response) => {
console.log('the event has been called', response);
}).catch((err) => {
console.log(err);
})
await Contract.triggerEventFunc().call();
}
Contract Code:
event PracticeEvent (string _message, uint _timestamp);
function checkEvent() public {
emit PracticeEvent("event has been called", gts);
}
---web3.js file
import Web3 from 'web3';
const web3 = new Web3(window.web3.currentProvider);
export default web3;
So when I run the app I get an error saying
"Uncaught (in promise) TypeError: Contract.default.events.PracticeEvent(...).watch is not a function"
This all works fine in Remix but it gets messed up when I try run it in my actual app
I'm assuming the bug has something to do with web3 but I'm not sure why because the web3 stuff is working fine in the rest of my app.
Any help? thanks!