Called

Event v334 → current #6

Emitted when a smart contract is called and executed.

View events on chain
Useful for: developersanalytics

The Big Picture

Every contract call execution is logged. Essential for tracing activity and analytics.

Use Cases

  • Track contract call activity
  • Monitor usage patterns
  • Debug interactions

From Chain Metadata

A contract was called either by a plain account or another contract.

Triggers

Preconditions

  • Contract exists
  • Caller provided sufficient gas

Effects

Storage Modified

Postconditions

  • Contract code executed
  • Gas consumed

Side Effects

  • Contract may have modified state
  • Contract may have emitted ContractEmitted events

Event Data

#NameTypeDescription
0
caller
Origin Account that initiated the contract call
1
contract
AccountId Contract that was called (hex -> SS58)

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 Called events
api.query.system.events((events) => {
  events
    .filter(({ event }) =>
      event.section === stringCamelCase("Contracts") &&
      event.method === "Called"
    )
    .forEach(({ event }) => {
      console.log("Called:", event.data.toHuman());
    });
});

Runtime Info

Pallet Index
29
Event Index
6
First Version
v334
Current Version
v393