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 { 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 });
// Subscribe to ContractEmitted events
api.query.system.events((events) => {
events
.filter(({ event }) =>
event.section === stringCamelCase("Contracts") &&
event.method === "ContractEmitted"
)
.forEach(({ event }) => {
console.log("ContractEmitted:", event.data.toHuman());
});
});Runtime Info
- Pallet Index
- 29
- Event Index
- 3
- First Version
- v334
- Current Version
- v393