U16
Primitive 42 v490About 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
- Variant: 0x00 = Ok (no payload), 0x01 = Err (followed by DispatchError).
- Size
- variable (1+ bytes)
Examples
Success (Ok) = Ok(())
0x0000 Variant index 0 = Ok, no payloadFailure (Err) = Err(DispatchError::BadOrigin)
0x010201 Variant index 1 = Err02 DispatchError variant 2 = BadOriginCode 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
- 42
- Kind
- Primitive
- Runtime
- v490