Tezex.Rpc (tezex v5.0.0)

Copy Markdown View Source

Send transactions to the Tezos network.

send_operation/4 is the main function, see tests for usage.

Summary

Types

encoded_private_key()

@type encoded_private_key() :: <<_::32, _::_*8>>

error_reason()

@type error_reason() ::
  transport_error()
  | {:missing_keys, [String.t()]}
  | {:preapply_failed, list()}
  | {:unexpected_response, term()}
  | {:invalid_counter, term()}
  | {:invalid_balance, term()}

operation()

@type operation() :: map()

preapplied_operations()

@type preapplied_operations() :: map()

t()

@type t() :: %Tezex.Rpc{
  chain_id: binary(),
  endpoint: binary(),
  headers: Finch.Request.headers(),
  opts: Finch.request_opts()
}

transaction()

@type transaction() :: map()

transport_error()

@type transport_error() ::
  {:transport, Exception.t()}
  | {:http_status, Finch.Response.t()}
  | {:decode, Jason.DecodeError.t()}

Functions

fill_operation_fee(operation, preapplied_operations, opts \\ [])

@spec fill_operation_fee(operation(), [preapplied_operations()],
  gas_limit: non_neg_integer(),
  storage_limit: non_neg_integer(),
  gas_reserve: non_neg_integer(),
  burn_reserve: non_neg_integer()
) :: {:ok, operation()} | {:error, Tezex.ForgeOperation.error_reason()}

forge_and_sign_operation(operation, encoded_private_key)

@spec forge_and_sign_operation(operation(), encoded_private_key()) ::
  {:ok, nonempty_binary()} | {:error, Tezex.ForgeOperation.error_reason()}

Sign the forged operation and returns the forged operation+signature payload to be injected.

get_balance(rpc, address)

@spec get_balance(t(), nonempty_binary()) ::
  {:ok, pos_integer()} | {:error, error_reason()}

get_block(rpc, hash \\ "head")

@spec get_block(t(), nonempty_binary()) :: {:ok, map()} | {:error, transport_error()}

get_block_at_offset(rpc, offset)

@spec get_block_at_offset(t(), integer()) ::
  {:ok, map()} | {:error, transport_error()}

get_counter_for_account(rpc, address)

@spec get_counter_for_account(t(), nonempty_binary()) ::
  {:ok, integer()} | {:error, error_reason()}

get_next_counter_for_account(rpc, address)

@spec get_next_counter_for_account(t(), nonempty_binary()) ::
  {:ok, integer()} | {:error, error_reason()}

inject_operation(rpc, payload)

@spec inject_operation(t(), any()) :: {:ok, any()} | {:error, transport_error()}

preapply_operation(rpc, operation, encoded_private_key, protocol)

@spec preapply_operation(t(), map(), encoded_private_key(), any()) ::
  {:ok, list()} | {:error, error_reason()}

Simulate the application of the operations with the context of the given block and return the result of each operation application.

prepare_operation(transactions, wallet_address, counter, branch)

@spec prepare_operation(
  [transaction()],
  nonempty_binary(),
  integer(),
  nonempty_binary()
) :: operation()

send_operation(rpc, transactions, wallet_address, encoded_private_key, opts \\ [])

@spec send_operation(
  t(),
  [transaction()] | transaction(),
  nonempty_binary(),
  encoded_private_key(),
  offset: non_neg_integer(),
  storage_limit: non_neg_integer()
) ::
  {:ok, any()} | {:error, error_reason()}

Send an operation to a Tezos RPC node.