IfElseFallbackCalled

Event v320 → current #7

Emitted when the main call failed and fallback was executed.

View events on chain
Useful for: developerswallets

The Big Picture

Main call failed, so fallback was executed.

Use Cases

  • Track fallback execution

From Chain Metadata

The fallback call was dispatched.

Triggers

Emitted by

Preconditions

  • if_else executed
  • Main failed

Effects

Postconditions

  • Fallback executed

Side Effects

  • Main error available

Event Data

#NameTypeDescription
0
main_error
DispatchError Error from the main call that triggered fallback

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 IfElseFallbackCalled events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.Utility.IfElseFallbackCalled.get(block.hash);
  for (const evt of events) {
    console.log("IfElseFallbackCalled:", evt.payload);
  }
});

Runtime Info

Pallet Index
11
Event Index
7
First Version
v320
Current Version
v411