🧩 SCALE Codec
Encode JSON into SCALE bytes or decode SCALE bytes back, using a type you describe.
Type syntax and value formats
Integers u8–u256, i8–i256 (large values as strings, e.g. "1000000000000"), bool, String, Bytes / Vec<u8> (0x hex), AccountId32 (SS58 or 0x hex), H160 / H256 / H512, Compact<T>, Vec<T>, Option<T> (null or a value), Result<T, E> ({"Ok": …} / {"Err": …}), [T; N], tuples (A, B) (JSON arrays), struct { a: T } (objects) and enum { A, B(T), C { x: T } } ("A" or {"B": …}).
Compact integers use the two lowest bits of the first byte as a mode: 00 one byte (values up to 63), 01 two bytes (up to 16383), 10 four bytes (up to 2³⁰−1), 11 “big integer” — the rest of the first byte is the number of following bytes minus 4. Vectors and strings start with a compact length. Option<bool> is a single byte: 0 None, 1 true, 2 false.