EventTopics

Storage Map v101 → current

Map of event topics to event indices.

Explore chain
Queried by: developersanalytics

The Big Picture

Allows finding events by their topic (usually event type hash).

Use Cases

  • Filter events by type

From Chain Metadata

Mapping between a topic (represented by T::Hash) and a vector of indexes of events in the `<Events<T>>` list. All topic vectors have deterministic storage locations depending on the topic. This allows light-clients to leverage the changes trie storage tracking mechanism and in case of changes fetch the list of events of interest. The value has the type `(T::BlockNumber, EventIndex)` because if we used only just the `EventIndex` then in case if the topic has the same contents on the next block no notification will be triggered thus the event might be lost.

Purpose & Usage

Purpose

Enable efficient event filtering by topic.

Common Query Patterns

  • Query by topic hash

Query Keys

#NameTypeDescription
1
key1
H256 key1 (H256)

Stored Value

value (Vec<(u32, u32)>)

Code Examples

import { ApiPromise, WsProvider } from "@polkadot/api";
import { stringCamelCase } from "@polkadot/util";

const provider = new WsProvider("wss://entrypoint-finney.opentensor.ai:443");
const api = await ApiPromise.create({ provider });

// Query EventTopics storage
const key1 = 0 as any /* H256 */;

const result = await api.query
  [stringCamelCase("System")]
  [stringCamelCase("EventTopics")](
  key1
);

console.log("EventTopics:", result.toHuman());

Runtime Info

Pallet
System
Storage Kind
Map
First Version
v101
Current Version
v393