Fund:0.012 ETH / $6.94
Question is solved

How do you listen for events with Web3?

1 month ago

How to listen for events with web3? Does it cost ETH to listen for events?


A user can listen for Ethereuem events by using Web3’s method. All events in Ethereuem are stored in the blockchain and is implemented with the LOG opcode. So you do not need to write any code for events you declare. You simply just write the name and the parameters. An event can have 3 indexed parameters, these indexed parameters can be used to filter for events to listen to in the front end.

For example, event PaymentReceived(address indexed _sender, address indexed _receiver, uint amount); Then we can listen for events by:

var paymentEvent = mycontract.PaymentReceived({_sender: someAddress});, result) => {...});

Here we only want to receive events that are send by a specific sender address.
1 month ago

Your question is successfully refund. You will be redirect in few seconds.