Tezex.Micheline (tezex v3.2.0)

View Source

Serialize/deserialize data to/from Tezos Micheline optimized binary representation.

Summary

Functions

Serialize a piece of data to its optimized binary representation.

Deserialize a piece of data from its optimized binary representation.

Types

pack_types()

@type pack_types() :: nil | :address | :bytes | :int | :key_hash | :nat | :string

unpack_result()

@type unpack_result() :: binary() | integer() | map() | [unpack_result()]

Functions

pack(value, type \\ nil)

@spec pack(binary() | integer() | map(), pack_types()) :: nonempty_binary()

Serialize a piece of data to its optimized binary representation.

Examples

iex> pack(-6407, :int)
"0500c764"
iex> pack(%{"prim" => "Pair", "args" => [%{"int" => "-33"}, %{"int" => "71"}]})
"0507070061008701"

unpack(hex_value, type \\ nil)

@spec unpack(binary(), pack_types()) :: unpack_result()

Deserialize a piece of data from its optimized binary representation.

Examples

iex> unpack("050a0000001601e67bac124dff100a57644de0cf26d341ebf9492600", :address)
"KT1VbT8n6YbrzPSjdAscKfJGDDNafB5yHn1H"
iex> unpack("0507070001000c")
%{"prim" => "Pair", "args" => [%{"int" => "1"}, %{"int" => "12"}]}