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> Vec Keyprefix (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 { 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 kill_prefix call (typed, named args)
const prefix = Binary.fromOpaque(new Uint8Array(0));
const subkeys = 0;

const tx = api.tx.System.kill_prefix({
  prefix,
  subkeys,
});

Runtime Info

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