Skip to content

How to get event's indexed argument value? #2171

Answered by ricmoo
0xSalman asked this question in Q&A
Discussion options

You must be logged in to vote

It is impossible to get the value of an indexed value of a type that does not fit into a bytes32. The Solidity compiled code implements an indexed value (for types that do not fit in a single EVM word) by hashing it and using a LOG operation to inject it into a topic.

If you require a string to be both indexed and access to its value, the event must emit both; for example event Foo(string indexed searchUsername, string username) which the searchUsername would by available in the log topics (and hence can be filtered via a bloom filter), and the username would be available in the log data.

It’s a bit complex and requires an understanding of how the Solidity compiler actually encodes events…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@0xSalman
Comment options

Answer selected by 0xSalman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants