U8
Primitive 2 v393About 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
0x2a2a 42 in hexMax (255) = 255
0xffff 255 = maximum u8Code 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