View Source OnFlow (on_flow v0.13.0)

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.

Link to this section Types

@type account() :: OnFlow.Entities.Account.t()
@type address() :: binary()
@type error() :: {:error, GRPC.RPCError.t()}
@type hex_string() :: String.t()
@type transaction_result() ::
  {:ok | :error, OnFlow.TransactionResponse.t()} | {:error, :timeout}

Link to this section Functions

Link to this function

create_account(credentials, public_key, opts \\ [])

View Source
@spec create_account(OnFlow.Credentials.t(), hex_string(), keyword()) ::
  {: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.

Available options are:

  • :gas_limit - the maximum amount of gas to use for the transaction. Defaults to 100.

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
@spec deploy_contract(OnFlow.Credentials.t(), String.t(), String.t(), keyword()) ::
  transaction_result()

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:

  • :gas_limit - the maximum amount of gas to use for the transaction. Defaults to 100.
  • :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
@spec 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, gas_limit, opts \\ [])

View Source

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.