Here is what the doc says:
Up to three parameters can receive the attribute indexed which will cause the respective arguments to be searched for: It is possible to filter for specific values of indexed arguments in the user interface.
OK, so I understand that I can define an event, for example, with three indexed parameters:
event Event(address indexed from, address indexed to, uint indexed id, uint value);
But what exactly is the benefit of using that indexed
keyword?
Up until now, I've been defining events with no indexing, for example:
event Event(uint value);
Then, on the web3-client side, I retrieve the value of the event as follows:
let hash = await myContract.myFunc(...);
let data = web3.toBigNumber(hash.receipt.logs[0].data);
If I know that several events are emitted during the execution on the blockchain side, then instead of 0
, I use the index of the specific event which I want to retrieve.
So I'm guessing that perhaps this indexed
keyword can be used in order to retrieve events on the client side in a cleaner manner.
Am I right, and if yes, how exactly would I retrieve an indexed event on the client side differently than how I am retrieving it at present?
Thank you.