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> Veccode (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 { 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 });

// Build apply_authorized_upgrade call
const code = 0;

const call = api.tx[stringCamelCase("System")][stringCamelCase("apply_authorized_upgrade")](
  code
);

Runtime Info

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