CodeStored
Event v334 → current #2Emitted when contract code is uploaded and stored on-chain.
View events on chainUseful for: developersanalytics
The Big Picture
Before contracts can be instantiated, code must be uploaded. This confirms code is on-chain. The code_hash uniquely identifies the code.
Use Cases
- Track new code uploads
- Build code registries
- Monitor developer activity
From Chain Metadata
Code with the specified hash has been stored.
Triggers
Preconditions
- Valid WASM code provided
- Code passes validation
- Caller has sufficient balance for deposit
Effects
Storage Modified
Postconditions
- Code stored in PristineCode
- CodeInfoOf populated
- Storage deposit charged
Side Effects
- Anyone can now instantiate using this code_hash
Event 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);
// Subscribe to CodeStored events
client.finalizedBlock$.subscribe(async (block) => {
const events = await api.event.Contracts.CodeStored.get(block.hash);
for (const evt of events) {
console.log("CodeStored:", evt.payload);
}
});Runtime Info
- Pallet Index
- 29
- Event Index
- 2
- First Version
- v334
- Current Version
- v411