U128

Primitive 8 v393

About This Type

Unsigned 128-bit integer for very large values.

Used when u64 is insufficient — typically for aggregated totals, accumulated rewards, or intermediate multiplication results that could overflow u64.

Encoding: Fixed-width: always exactly 16 bytes, little-endian.

If representing RAO: divide by 10^9 for TAO.

Common Uses

  • • Aggregate stake totals
  • • Large intermediate calculations

Primitive Type

Name
U128
Byte Size
16 bytes
SCALE Encoding
Fixed-width, little-endian

SCALE Encoding

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

Examples

1 TAO (u128) = 1,000,000,000
0x00ca9a3b000000000000000000000000
00ca9a3b...(16 bytes) 16 bytes little-endian

Code Examples

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

const registry = new TypeRegistry();

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

Type Information

Type ID
8
Kind
Primitive
Runtime
v393