kill_prefix

Call v101 → current #6

Remove all storage items with a given prefix (root only).

View calls on chain

Click items to navigate. Pan and zoom to explore.

Used by: validatorsdevelopers

The Big Picture

Bulk deletion of storage by prefix. When a pallet is removed, this removes all its storage.

Use Cases

  • Remove entire pallet storage
  • Clean up all map entries

From Chain Metadata

Kill all storage items with a key that starts with the given prefix. **NOTE:** We rely on the Root origin to provide us the number of subkeys under the prefix we are removing to accurately calculate the weight of this function.

Input Parameters

#NameTypeDescription
0
prefix
Vec<u8> Vecprefix (Vec<u8>)
1
subkeys
u32 subkeys (u32)

Permissions

Origin
Unknown
Required Role

Permission data inferred from metadata. May be incomplete.

Requirements

  • Caller is root/sudo
  • Valid storage prefix
  • Accurate subkey count

Effects

Postconditions

  • All matching storage items deleted

Side Effects

  • Can delete large amounts of data

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 kill_prefix call
const prefix = 0;
const subkeys = 0;

const call = api.tx[stringCamelCase("System")][stringCamelCase("kill_prefix")](
  prefix,
  subkeys
);

Runtime Info

Pallet Index
0
Call Index
6
First Version
v101
Current Version
v393