apply_authorized_upgrade

Call v151 → current #11

Apply a previously authorized runtime upgrade (any origin).

View calls on chain

Click items to navigate. Pan and zoom to explore.

Used by: validatorsdevelopers

The Big Picture

The execution half of authorize/apply. Anyone with matching code can deploy it.

Use Cases

  • Apply governance-approved upgrades
  • Decentralized upgrade execution

From Chain Metadata

Provide the preimage (runtime binary) `code` for an upgrade that has been authorized. If the authorization required a version check, this call will ensure the spec name remains unchanged and that the spec version has increased. Depending on the runtime's `OnSetCode` configuration, this function may directly apply the new `code` in the same block or attempt to schedule the upgrade. All origins are allowed.

Input Parameters

#NameTypeDescription
0
code
Vec<u8> Vec code (Vec<u8>)

Permissions

Origin
Unknown
Required Role

Permission data inferred from metadata. May be incomplete.

Requirements

  • Upgrade has been authorized
  • Code hash matches authorization

Effects

Postconditions

  • Runtime code deployed
  • CodeUpdated event emitted
  • Authorization cleared

Side Effects

  • Chain behavior changes from next block

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);

// Build apply_authorized_upgrade call (typed, named args)
const code = Binary.fromOpaque(new Uint8Array(0));

const tx = api.tx.System.apply_authorized_upgrade({
  code,
});

Runtime Info

Pallet Index
0
Call Index
11
First Version
v151
Current Version
v411