CodeRemoved

Event v334 → current #4

Emitted when contract code is removed from on-chain storage .

View events on chain
Useful for: developersanalytics

The Big Picture

When code is no longer needed, the uploader can remove it to reclaim their deposit.

Use Cases

  • Track code cleanup
  • Monitor storage reclamation
  • Update code registries

From Chain Metadata

A code with the specified hash was removed.

Triggers

Emitted by

Preconditions

  • Code exists
  • No contract instances reference this code
  • Caller is original uploader

Effects

Storage Modified

Postconditions

  • Code removed
  • CodeInfoOf cleared
  • Deposit refunded

Side Effects

  • Code hash no longer available for instantiation

Event Data

#NameTypeDescription
0
code_hash
H256 T::HashHash of the removed code
1
deposit_released
u64 BalanceOf<T>Amount of deposit refunded (RAO) (RAO -> TAO (/ 10^9))
2
remover
AccountId Account that removed the code (original uploader) (hex -> SS58)

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

// Subscribe to CodeRemoved events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.Contracts.CodeRemoved.get(block.hash);
  for (const evt of events) {
    console.log("CodeRemoved:", evt.payload);
  }
});

Runtime Info

Pallet Index
29
Event Index
4
First Version
v334
Current Version
v411