I am using web socket to get event. sending transaction works fine. but event is not fired.
also I referred Web3 events not working
but it does not work, too.
I used eventemitter also. but it did not work, too. I think there is a problem '.on'. Is there any similar case to me ?
My solidity code is:
event MyEvent(...);
function MyFunction(...) public {
...
emit MyEvent(...);
}
My node.js code is :
const events = require('events');
const WSS = 'ws://localhost:8881';
const provider = new Web3.providers.WebsocketProvider(WSS);
const web3 = new Web3(provider);
const eventEmitter = new events.EventEmitter();
myContract.events.MyEvent({
//filter: {myIndexedParam: [20,23]},
fromBlock: 0,
toBlock: 'latest'
});
eventEmitter.on('data', e => {
console.log(e.returnValues);
});
eventEmitter.on('error', e => {
console.error(e);
});
// ...
// sending transaction
// ...