Queried by: developersanalytics
The Big Picture
Metadata about uploaded code: who uploaded it (and can remove it), how much deposit is held, and how many contract instances reference it. Essential for code lifecycle management.
Use Cases
- Check if code hash exists on-chain
- Find code owner for removal
- Analyze code usage (refcount)
- Track deposit amounts
From Chain Metadata
A mapping from a contract's code hash to its code info.
Purpose & Usage
Purpose
Tracks code properties like owner, deposit, and reference count.
Common Query Patterns
- Query by code_hash for code metadata
- Check refcount before code removal
- Verify code exists
Query Keys
| # | Name | Type | Description |
|---|---|---|---|
| 1 | key1 | H256 | key1 (H256) |
Stored Value
value (CodeInfo)
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 CodeInfoOf storage
const key1 = 0 as any /* H256 */;
const result = await api.query
[stringCamelCase("Contracts")]
[stringCamelCase("CodeInfoOf")](
key1
);
console.log("CodeInfoOf:", result.toHuman());Runtime Info
- Pallet
- Contracts
- Storage Kind
- Map
- First Version
- v334
- Current Version
- v393