Code

Variant 620 v393

pallet_contracts::primitives::Code

About This Type

Enum type: Code.

A tagged union where the first byte selects which variant is active, followed by that variant's data.

Encoding: 1-byte variant index followed by the selected variant's field data.

Variants (2)

IndexNameFieldsDocs
0Upload
1Existing

SCALE Encoding

Rule
1-byte variant index followed by variant-specific field data. 2 possible variants.
Size
variable (1+ bytes)

Examples

Upload = Upload(Vec<u8>)
0x00<field0>
00 Variant index 0 = Upload
field 0 field0: Vec<u8>
Existing = Existing(H256)
0x01<field0>
01 Variant index 1 = Existing
field 0 field0: H256

Code Examples

import { TypeRegistry } from "@polkadot/types";

const registry = new TypeRegistry();

// Encode Code — variant "Upload"
const value = registry.createType("Code", { Upload: { value: 0 } });
console.log("Hex:", value.toHex());

Type Parameters

Hash = H256

Type Information

Type ID
620
Kind
Variant
Path
pallet_contracts::primitives::Code
Runtime
v393