Terminated

Event v334 → current #1

Emitted when a contract is terminated and removed from the chain.

View events on chain
Useful for: developersanalytics

The Big Picture

Contract termination ends a contract's lifecycle. Code is unlinked, storage cleared, deposits refunded.

Use Cases

  • Track contract lifecycle events
  • Detect self-destructing contracts
  • Update contract registries

From Chain Metadata

Contract has been removed.

Triggers

Preconditions

  • Contract exists
  • Termination triggered

Effects

Postconditions

  • Contract no longer exists
  • ContractInfoOf cleared
  • Storage deposits refunded

Side Effects

  • Contract can no longer be called
  • Remaining balance transferred to beneficiary

Event Data

#NameTypeDescription
0
contract
AccountId The terminated contract's address (hex -> SS58)
1
beneficiary
AccountId Account receiving remaining contract balance (hex -> SS58)

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

// Subscribe to Terminated events
api.query.system.events((events) => {
  events
    .filter(({ event }) =>
      event.section === stringCamelCase("Contracts") &&
      event.method === "Terminated"
    )
    .forEach(({ event }) => {
      console.log("Terminated:", event.data.toHuman());
    });
});

Runtime Info

Pallet Index
29
Event Index
1
First Version
v334
Current Version
v393