View Source Tezex.Forge (tezex v2.0.0)

Convert Tezos Micheline data from/to binary form for injection into the Tezos blockchain (aka forging/unforging Micheline).

Mostly ported from pytezos@9352c4579e436b92f8070343964af20747255197

pytezos / MIT License / (c) 2020 Baking Bad / (c) 2018 Arthur Breitman

Summary

Functions

Encode a signed unbounded integer into byte form.

Encode a Micheline expression into byte form.

Encode a non-negative integer using LEB128 encoding.

Decode a contract (address + optional entrypoint) from bytes, returning a string with the base58 encoded address and, if present, the entrypoint separated by %.

Decode a signed unbounded integer from bytes.

Parse Micheline map from bytes.

Types

@type io_encoding() :: :bytes | :hex

Functions

Link to this function

forge_address(value, output_encoding \\ :bytes, tz_only \\ false)

View Source
@spec forge_address(binary(), io_encoding(), boolean()) :: nonempty_binary()

Encode address or key hash into bytes.

  • value is a base58 encoded address or key_hash
  • tz_only indicates that it's a key_hash (will be encoded in a more compact form)
Link to this function

forge_array(data, output_encoding \\ :bytes, len_bytes \\ 4)

View Source
@spec forge_array(binary(), io_encoding(), non_neg_integer()) :: binary()
Link to this function

forge_base58(value, output_encoding \\ :bytes)

View Source
@spec forge_base58(binary(), io_encoding()) :: binary()
Link to this function

forge_bool(value, output_encoding \\ :bytes)

View Source
@spec forge_bool(boolean(), io_encoding()) :: nonempty_binary()
Link to this function

forge_contract(value, output_encoding \\ :bytes)

View Source
@spec forge_contract(binary(), io_encoding()) :: binary()
Link to this function

forge_int16(value, output_encoding \\ :bytes)

View Source
@spec forge_int16(integer(), io_encoding()) :: nonempty_binary()
Link to this function

forge_int32(value, output_encoding \\ :bytes)

View Source
@spec forge_int32(integer(), io_encoding()) :: nonempty_binary()
Link to this function

forge_int(value, output_encoding \\ :bytes)

View Source
@spec forge_int(integer(), io_encoding()) :: nonempty_binary()

Encode a signed unbounded integer into byte form.

Link to this function

forge_micheline(data, output_encoding \\ :bytes)

View Source
@spec forge_micheline(list() | map(), io_encoding()) :: binary()

Encode a Micheline expression into byte form.

Link to this function

forge_nat(value, output_encoding \\ :bytes)

View Source
@spec forge_nat(non_neg_integer(), io_encoding()) :: nonempty_binary()

Encode a non-negative integer using LEB128 encoding.

Link to this function

forge_public_key(value, output_encoding \\ :bytes)

View Source
@spec forge_public_key(binary(), io_encoding()) :: nonempty_binary()
Link to this function

forge_script(script, output_encoding \\ :bytes)

View Source
@spec forge_script(map(), io_encoding()) :: binary()
Link to this function

forge_script_expr(packed_key, output_encoding \\ :bytes)

View Source
@spec forge_script_expr(binary(), io_encoding()) :: nonempty_binary()
Link to this function

optimize_timestamp(value)

View Source
@spec optimize_timestamp(binary()) :: integer()
Link to this function

unforge_address(data, input_encoding \\ :bytes)

View Source
@spec unforge_address(binary(), io_encoding()) :: nonempty_binary()
Link to this function

unforge_array(data, input_encoding \\ :bytes, len_bytes \\ 4)

View Source
@spec unforge_array(binary(), io_encoding(), non_neg_integer()) ::
  {binary(), non_neg_integer()}
Link to this function

unforge_chain_id(data, input_encoding \\ :bytes)

View Source
@spec unforge_chain_id(binary(), io_encoding()) :: nonempty_binary()
Link to this function

unforge_contract(data, input_encoding \\ :bytes)

View Source
@spec unforge_contract(binary(), io_encoding()) :: nonempty_binary()

Decode a contract (address + optional entrypoint) from bytes, returning a string with the base58 encoded address and, if present, the entrypoint separated by %.

Link to this function

unforge_int(data, input_encoding \\ :bytes)

View Source
@spec unforge_int(binary(), io_encoding()) :: {integer(), non_neg_integer()}

Decode a signed unbounded integer from bytes.

Link to this function

unforge_micheline(data, input_encoding \\ :bytes)

View Source
@spec unforge_micheline(binary(), io_encoding()) :: list() | map()

Parse Micheline map from bytes.

Link to this function

unforge_public_key(data, input_encoding \\ :bytes)

View Source
@spec unforge_public_key(binary(), io_encoding()) :: nonempty_binary()
Link to this function

unforge_signature(data, input_encoding \\ :bytes)

View Source
@spec unforge_signature(binary(), io_encoding()) :: nonempty_binary()