Overview
Event.encodeTopics builds the topics array for an event filter. It includes topic0 (the event selector) for non-anonymous events and encodes indexed parameters as topics.
Quick Start
Wildcards and Partial Filters
Set an indexed value tonull (or omit it) to leave that topic unconstrained:
Use in Log Filters
encodeTopics returns byte arrays. Convert to hex strings when passing to JSON-RPC:
Dynamic Indexed Parameters
Dynamic types (string, bytes, dynamic arrays, tuples with dynamic parts) are hashed with keccak256 before being placed in a topic. You cannot recover the original value from the topic alone.
Anonymous Events
Anonymous events omittopic0. encodeTopics will return only the indexed parameter topics.
See Also
- decodeLog - Decode log data + topics
- getSelector - Compute topic0 selector
- Selectors - Selector rules

