ContractEmitted
Event v334 → current #3Emitted when a contract emits a custom event during execution.
View events on chainUseful for: developersanalytics
The Big Picture
Contracts can emit their own events. This wraps those custom events. The data field contains contract-defined data that must be decoded using the contract's ABI.
Use Cases
- Monitor contract-specific events
- Build contract-aware indexers
- Debug contract execution
From Chain Metadata
A custom event emitted by the contract.
Triggers
Emitted by
Preconditions
- Contract is executing
- Contract calls seal_deposit_event
Effects
Storage Modified
Postconditions
- Custom event data recorded
Side Effects
- Gas consumed for event emission
Event Data
Code Examples
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Subscribe to ContractEmitted events
client.finalizedBlock$.subscribe(async (block) => {
const events = await api.event.Contracts.ContractEmitted.get(block.hash);
for (const evt of events) {
console.log("ContractEmitted:", evt.payload);
}
});Runtime Info
- Pallet Index
- 29
- Event Index
- 3
- First Version
- v334
- Current Version
- v411