Queried by: developersanalytics
The Big Picture
All contract code lives here, indexed by code_hash. Multiple contracts can share the same code (same hash). This separation allows efficient code reuse and independent code/instance lifecycle.
Use Cases
- Retrieve contract source code by hash
- Verify code integrity
- Analyze uploaded contracts
- Build code browsers/explorers
From Chain Metadata
A mapping from a contract's code hash to its code.
Purpose & Usage
Purpose
Holds the original WASM bytecode for smart contracts.
Common Query Patterns
- Query by code_hash to retrieve WASM code
- Check existence before instantiation
Query Keys
| # | Name | Type | Description |
|---|---|---|---|
| 1 | key1 | H256 | key1 (H256) |
Stored Value
value (BoundedVec)
Relationships
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 });
// Query PristineCode storage
const key1 = 0 as any /* H256 */;
const result = await api.query
[stringCamelCase("Contracts")]
[stringCamelCase("PristineCode")](
key1
);
console.log("PristineCode:", result.toHuman());Runtime Info
- Pallet
- Contracts
- Storage Kind
- Map
- First Version
- v334
- Current Version
- v393