Filter an indexed Solidity string in an event
Event search works differently for a dynamic indexed string than for a plain address. The topic holds a digest that lets you search for a known value.
Build a filter for a known label
Consider a non-anonymous event Tagged(string indexed label,uint256 value). Its first topic is the event signature hash. For the top-level indexed string blue, the next topic is Keccak-256 of the four UTF-8 bytes shown below.
blue → 0x626c7565
Use both topics and the emitting contract address in eth_getLogs. Decode value from the data field as a uint256. Hashing the usual length-prefixed ABI encoding of blue would produce a different topic.
Account for information lost in indexing
Given only the digest, a decoder cannot recover an arbitrary original string. If an application needs both efficient filtering and display text, the event design can emit a second, unindexed copy. Arrays and structs use additional rules for indexed encoding. docs.soliditylang.org Solidity ABI