U16

Primitive 40 v393

About This Type

Unsigned 16-bit integer (0 to 2^16 - 1).

Fixed-width 2-byte unsigned integer.

Encoding: Fixed-width: 2 bytes, little-endian.

Primitive Type

Name
U16
Byte Size
2 bytes
SCALE Encoding
Fixed-width, little-endian

SCALE Encoding

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

Examples

Subnet 1 = 1
0x0100
01 00 1 as u16 little-endian
Subnet 256 = 256
0x0001
00 01 256 as u16 little-endian (0x0100 LE)

Code Examples

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

const registry = new TypeRegistry();

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

Type Information

Type ID
40
Kind
Primitive
Runtime
v393