-
hi all, Is there a way to get the actual value of the indexed argument of an event? I have an event like this:
and I have this code that queries this event and logs the event arguments. I am getting the hashed value of
I would really appreciate any help, thank you!! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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 It’s a bit complex and requires an understanding of how the Solidity compiler actually encodes events and topics, but does that somewhat make sense? |
Beta Was this translation helpful? Give feedback.
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 thesearchUsername
would by available in the log topics (and hence can be filtered via a bloom filter), and theusername
would be available in the log data.It’s a bit complex and requires an understanding of how the Solidity compiler actually encodes events…