Instantiated

Event v334 → current #0

Emitted when a new smart contract is successfully deployed and instantiated.

View events on chain
Useful for: developersanalytics

The Big Picture

This event marks the birth of a new smart contract. The deployer and contract address are recorded. From this moment, the contract can be called and will execute its WASM code.

Use Cases

  • Track new contract deployments
  • Index deployed contracts by address
  • Monitor deployment activity
  • Build contract registries

From Chain Metadata

Contract deployed by address at the specified address.

Triggers

Preconditions

  • Valid WASM code provided or code_hash exists in PristineCode
  • Caller has sufficient balance for storage deposits
  • Constructor execution succeeded

Effects

Postconditions

  • Contract exists at the emitted address
  • ContractInfoOf storage populated
  • Code reference count incremented

Side Effects

  • Constructor may have modified contract storage
  • Constructor may have emitted ContractEmitted events

Event Data

#NameTypeDescription
0
deployer
AccountId Account that deployed the contract and paid deposits (hex -> SS58)
1
contract
AccountId The deployed contract's unique address (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 Instantiated events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.Contracts.Instantiated.get(block.hash);
  for (const evt of events) {
    console.log("Instantiated:", evt.payload);
  }
});

Runtime Info

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