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.
| Mode | First byte | Range | Example |
|---|---|---|---|
| single-byte | xxxxxx00 | 0 – 63 | 42 → a8 |
| two-byte | xxxxxx01 | 64 – 16,383 | 69 → 1501 |
| four-byte | xxxxxx10 | 16,384 – 2³⁰−1 | 16384 → 02000100 |
| big-integer | xxxxxx11 | 2³⁰ – 2⁵³⁶−1 | 2³⁰ → 0300000040 |
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.
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.
| Vector | Expected hex |
|---|
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).