Vec<u8>

Sequence 15 v490

About This Type

Variable-length list of u8 values.

A dynamically-sized collection. The encoded length precedes the element data.

Encoding: Compact<u32> length prefix followed by each element encoded in sequence.

Sequence (Vec)

Element Type
u8
SCALE Encoding
Length-prefixed (Compact<u32> length followed by elements)

SCALE Encoding

Rule
Compact<u32> length prefix followed by each u8 element encoded in sequence.
Size
variable

Examples

Byte vector [1, 2, 3] = [1, 2, 3]
0x0c010203
0c Compact length = 3 (3 << 2 = 12 = 0x0C)
01 02 03 3 raw bytes
Empty vector = []
0x00
00 Compact length = 0

Code Examples

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

const registry = new TypeRegistry();

// Encode a Vec<u8>
const vec = registry.createType("Vec<u8>", [1, 2, 3]);
console.log("Hex:", vec.toHex());

Referenced By (111)

and 91 more...

Type Information

Type ID
15
Kind
Sequence
Runtime
v490