Str
Primitive 80 v393About This Type
UTF-8 string.
Variable-length text data.
Encoding: Compact<u32> byte length prefix followed by UTF-8 bytes.
Primitive Type
- Name
- Str
- SCALE Encoding
- Fixed-width, little-endian
SCALE Encoding
- Rule
- Compact<u32> byte length prefix followed by UTF-8 bytes.
- Size
- variable
Examples
"Hello" = Hello
0x1448656c6c6f14 Compact length = 5 (5 << 2 = 20 = 0x14)48 65 6c 6c 6f UTF-8 bytes for "Hello"Code Examples
import { TypeRegistry } from "@polkadot/types";
const registry = new TypeRegistry();
// Encode a Str value
const value = registry.createType("Str", 0);
console.log("Hex:", value.toHex());
console.log("Bytes:", value.toU8a());Type Information
- Type ID
- 80
- Kind
- Primitive
- Runtime
- v393