dispatch_as_fallible

Call v320 → current #7

Dispatches a call as a different origin, forwarding any errors (root only).

View calls on chain

Click items to navigate. Pan and zoom to explore.

Used by: validatorsdevelopers

The Big Picture

Similar to dispatch_as, but forwards any error from the inner call instead of swallowing it. Useful when the result of the dispatched call needs to be checked and acted upon.

Use Cases

  • Administrative actions on behalf of other origins
  • Testing and debugging with specific origins
  • Protocol-level operations requiring origin switching

From Chain Metadata

Dispatches a function call with a provided origin. Almost the same as [`Pallet::dispatch_as`] but forwards any error of the inner call. The dispatch origin for this call must be _Root_.

Input Parameters

#NameTypeDescription
0
as_origin
OriginCaller Box<T::PalletsOrigin>as_origin (OriginCaller)
1
call
RuntimeCall Box<<T as Config>::RuntimeCall>call (RuntimeCall)

Permissions

Origin
Root
Required Role

Permission data inferred from metadata. May be incomplete.

Requirements

  • Caller is root account
  • Target origin is valid

Effects

Events Emitted

Postconditions

  • Call executed with specified origin
  • DispatchedAs event emitted with result

Side Effects

  • Allows root to execute calls as other origins
  • Errors from inner call are propagated

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 dispatch_as_fallible call (typed, named args)
const as_origin = undefined as any /* OriginCaller — replace with real value */;
const call = undefined as any /* RuntimeCall — replace with real value */;

const tx = api.tx.Utility.dispatch_as_fallible({
  as_origin,
  call,
});

Runtime Info

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