Call Workflow
Click items to navigate. Pan and zoom to explore.
From Chain Metadata
Dispatch a fallback call in the event the main call fails to execute. May be called from any origin except `None`. This function first attempts to dispatch the `main` call. If the `main` call fails, the `fallback` is attemted. if the fallback is successfully dispatched, the weights of both calls are accumulated and an event containing the main call error is deposited. In the event of a fallback failure the whole call fails with the weights returned. `main`: The main call to be dispatched. This is the primary action to execute. `fallback`: The fallback call to be dispatched in case the `main` call fails. ## Dispatch Logic If the origin is `root`, both the main and fallback calls are executed without applying any origin filters. If the origin is not `root`, the origin filter is applied to both the `main` and `fallback` calls. ## Use Case Some use cases might involve submitting a `batch` type call in either main, fallback or both.
Input Parameters
| # | Name | Type | Description |
|---|---|---|---|
| 0 | main | RuntimeCall Box<<T as Config>::RuntimeCall> | main (RuntimeCall) |
| 1 | fallback | RuntimeCall Box<<T as Config>::RuntimeCall> | fallback (RuntimeCall) |
Permissions
Permission data inferred from metadata. May be incomplete.
Requirements
- Main and fallback calls provided
Effects
Events Emitted
Postconditions
- Main call executed, or fallback on failure
Side Effects
- Enables conditional execution patterns
Code Examples
// ----------------------------------------------------------------------
// HEADS UP: 2 args below have a complex type with no usable default.
// Look for `undefined as any` and replace them with real values
// before running — the snippet compiles, but will fail at runtime as-is.
// ----------------------------------------------------------------------
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);
// Build if_else call (typed, named args)
const main = undefined as any /* RuntimeCall — replace with real value */;
const fallback = undefined as any /* RuntimeCall — replace with real value */;
const tx = api.tx.Utility.if_else({
main,
fallback,
});Runtime Info
- Pallet Index
- 11
- Call Index
- 6
- First Version
- v320
- Current Version
- v411