OnFlow (on_flow v0.2.0) View Source

Link to this section Summary

Functions

Creates a Flow account. Note that an existing account must be passed in as the first argument, since internally this is executed as a transaction on the existing account.

Deploys a contract to an account. This just takes in existing account credentials, the name of the contract, and the contract code. Internally, this is just a single-signer, single-authorizer transaction.

Executes a script on the Flow network to show account data.

Returns a binary of the latest block ID. This is typically used as a reference ID when sending transactions to the network.

Fetches the transaction result for a given transaction ID.

Sends a transaction. Options

Link to this section Types

Specs

account() :: OnFlow.Entities.Account.t()

Specs

address() :: binary()

Specs

error() :: {:error, GRPC.RPCError.t()}

Specs

hex_string() :: String.t()

Specs

transaction_result() ::
  {:ok | :error, OnFlow.Access.TransactionResultResponse.t()}
  | {:error, :timeout}

Link to this section Functions

Link to this function

create_account(credentials, public_key)

View Source

Specs

create_account(OnFlow.Credentials.t(), hex_string()) ::
  {:ok, hex_string()} | transaction_result()

Creates a Flow account. Note that an existing account must be passed in as the first argument, since internally this is executed as a transaction on the existing account.

On success, it returns {:ok, address}, where address is a hex-encoded representation of the address.

On failure, it returns {:error, response} or {:error, :timeout}.

Link to this function

deploy_contract(credentials, name, contract, opts \\ [])

View Source

Specs

Deploys a contract to an account. This just takes in existing account credentials, the name of the contract, and the contract code. Internally, this is just a single-signer, single-authorizer transaction.

Options:

  • :update? - either true or false to update a previously deployed contract with the same name.
Link to this function

execute_script(code, args \\ [])

View Source

Specs

get_account(address()) :: {:ok, account()} | error()

Executes a script on the Flow network to show account data.

Returns a binary of the latest block ID. This is typically used as a reference ID when sending transactions to the network.

Link to this function

get_transaction_result(id)

View Source

Fetches the transaction result for a given transaction ID.

Link to this function

send_transaction(script, signers, opts \\ [])

View Source

Specs

Sends a transaction. Options:

  • :args - the list of objects that will be sent along with the transaction. This must be an Elixir list that can be encoded to JSON.
  • :authorizers - a list of authorizing %Credentials{} structs to authorize the transaction.
  • :payer - a hex-encoded address or %Credentials{} struct that will pay for the transaction.
  • :wait_until_sealed? - either true or false. Note that if the transaction is not sealed after 30 seconds, this will return {:error, :timeout}. Defaults to true.