Hey guys I'm terribly stuck with getting events to frontend. I'm using MetaMask. what am I missing?

Solidity event:

event enrolled(address payoutAddress, address sender, uint dateOfTransaction);

And Web3:

MyContract = web3.eth.contract(abi);
    myContractInstance = MyContract.at(contractAddress);
    var depositEventAll = myContractInstance.enrolled({dateOfTransaction: userAddr}, {fromBlock: 4400000, toBlock: 'latest'});
    depositEventAll.watch(function (err, result) {
        if (err) {


  • {dateOfTransaction: userAddr} seems suspicious. Are you sure your filter is correct? Did you mean {address: userAddr} instead? – smarx Oct 24 '17 at 17:47

There are currently some issues with how MetaMask handles events. It’s always been a hard API to support, because unlike every other method, it’a stateful.

I’m sorry to say that until this internal behavior is stabilized, I need to recommend initializing a second provider if you want to use events, and either point it at a backend you control, or use web3-provider-engine to polyfill the event behavior (metamask is in the process of moving off provider-engine, hence the current instability).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.