← Builder hub
QTC SCALE LabThe codec workbench
100% client-side
Apps

The SCALE codec workbench

Every byte Quantus puts on the wire is SCALE-encoded — extrinsics, storage keys, RPC payloads. This lab lets you encode and decode the codec by hand: canonical compact integers in all four modes, every primitive, options / vecs / structs / enums, SS58 addresses on prefix 189, and twox_128 storage keys. Strict mode rejects non-canonical encodings — the same check that caught a real mode-2 decode bug in this builder's own tooling. Nothing leaves your browser.

Encode canonical

Enter an integer (decimal or 0x hex). The lab always emits the single canonical encoding — smallest mode, minimal bytes.

Decode strict

Paste compact bytes. Strict mode rejects non-canonical encodings (bloated modes, padded big-ints) — lax mode still decodes but flags them.

The four modes

The two low bits of the first byte select the mode. Click a notorious value to load it into the decoder.

ModeFirst byteRangeExample
single-bytexxxxxx000 – 6342 → a8
two-bytexxxxxx0164 – 16,38369 → 1501
four-bytexxxxxx1016,384 – 2³⁰−116384 → 02000100
big-integerxxxxxx112³⁰ – 2⁵³⁶−12³⁰ → 0300000040
Why strict matters. A decoder that doesn't check canonicality will happily read bloated encodings — and a decoder that mis-handles mode 2 (like this builder's own extrinsic decoder did before 2026-09-30) silently corrupts every amount between 16,384 and 1,073,741,823 plancks. When you verify someone else's bytes, decode strictly.

Schema struct builder

Build a struct field-by-field, fill in values, and encode it — or paste hex and decode it back with the same schema. Integers accept decimal or 0x hex (BigInt-safe); bytes/accountid accept hex; bool is true/false; str is plain text; balance is plancks (shown in QTC too).

Encode

Decode

Encode pubkey → SS58

32-byte public key as hex → Quantus SS58 address (prefix 189 → prefix bytes 6f40, checksum = blake2b-512("SS58PRE" ‖ body)[0..2]).

Verify SS58 → anatomy

Paste any SS58 address. The lab checks the base58 alphabet, the prefix (warns if it isn't Quantus 189), the key length, and the checksum.

Plain storage key

twox_128(pallet) ‖ twox_128(item) — the 32-byte key for plain (non-map) storage values. The chain hashes with XxHash64 seeds 0 and 1 (verified against the chain's sp-crypto-hashing).

Map storage key

Plain key + the map hasher applied to your key bytes: Blake2_128Concat (e.g. System.Account), Twox64Concat, or Identity.

Tip: copy a forged key into the Chain Console's storage reader (state_getStorage) to read the value live from a node.

Canonical test vectors run live

The spec table this codec is held to. "Run all" executes every vector in your browser right now — green means this page's codec matches the canonical SCALE spec and the chain-verified hash anchors.

VectorExpected hex
Anchors. Compact/primitive vectors are the canonical parity-scale-codec spec table. twox_128("System") is cross-checked against @polkadot/util-crypto (2026-09-30). SS58 vectors round-trip through an independent node:crypto checksum check in the repo's test suite (tests/run-tests.mjs — 62 assertions).