Dispatched

Event v133 → current #2

Emitted when a scheduled task is executed.

View events on chain
Useful for: developersanalytics

The Big Picture

The actual execution of a scheduled call - includes dispatch result for success/failure.

Use Cases

  • Track task execution outcomes
  • Monitor scheduled operations

From Chain Metadata

Dispatched some task.

Triggers

Preconditions

  • Block reached scheduled time
  • Task existed in Agenda

Effects

Postconditions

  • Task executed (success or failure recorded in result)

Side Effects

  • Side effects of the dispatched call
  • May reschedule if periodic

Event Data

#NameTypeDescription
0
task
(u32, u32) Task address as (block_number, index) tuple
1
id
Option Optional 32-byte task name (None for anonymous tasks)
2
result
Result Dispatch result (Ok or Err with error details)

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

Runtime Info

Pallet Index
15
Event Index
2
First Version
v133
Current Version
v393