Skip to main content

Module serialization

Module serialization 

Source
Expand description

Serialization helpers for arknet.

  • borsh is the only encoding used for on-chain bytes. Canonical, deterministic, consensus-critical. Every struct on the wire must derive BorshSerialize + BorshDeserialize.
  • JSON is used for human-facing surfaces: RPC responses, config dumps, CLI output.
  • Hex is used for displaying hashes / keys in logs and error messages.

Functionsยง

from_borsh
Decode a borsh-encoded byte slice.
from_hex
Decode hex with or without a 0x prefix.
from_json
Decode a JSON string.
to_borsh
Encode a value to canonical borsh bytes.
to_hex
Encode bytes as lowercase hex with no 0x prefix.
to_json
Encode a value as JSON.
to_json_pretty
Encode a value as pretty-printed JSON (for CLI output).