as-scale-codec
AS implementation of SCALE Codec
Overview
as-scale-codec
is an AssemblyScript implementation of Polkadot SCALE Codec. The codec is used as a communication mechanism between Substrate Hosts and Substrate Runtimes.
This is an integral part of the Subsembly
, since it provides SCALE encoding and decoding functionality for the types.
The library is maintained by LimeChain and has improved significantly over the course of Subsembly
development.
Codec
Every Subsembly
type needs to have encoding and decoding features, which is provided from the Codec
interface of as-scale-codec
. If you were to create your custom type to use in your Subsembly
runtime, type has to implement Codec
interface.
Examples
Encoding
Every type has а toU8a function. It encodes type value into an array of bytes
Decoding
We can decode arbitrary bytes into as-scale-codec using BytesReader:
For more information, please visit as-scale-codec and SCALE docs.
Last updated