U8

Primitive 2 v393

About This Type

Unsigned 8-bit integer (0–255).

Used for small values like flags, percentages, and single-byte identifiers.

Encoding: Fixed-width: always exactly 1 byte.

Common Uses

  • • Boolean-like flags
  • • Small configuration values

Primitive Type

Name
U8
Byte Size
1 byte
SCALE Encoding
Fixed-width, little-endian

SCALE Encoding

Rule
Fixed-width 1-byte unsigned integer, little-endian.
Size
1 byte

Examples

Value 42 = 42
0x2a
2a 42 in hex
Max (255) = 255
0xff
ff 255 = maximum u8

Code Examples

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

const registry = new TypeRegistry();

// Encode a U8 value
const value = registry.createType("U8", 42);
console.log("Hex:", value.toHex());
console.log("Bytes:", value.toU8a());

Type Information

Type ID
2
Kind
Primitive
Runtime
v393