View Source Xogmios.StateQuery (xogmios v0.8.0)

This module interfaces with the State Query protocol.

Summary

Functions

Sends a State Query call to the server and returns a response.

Starts a new State Query process linked to the current process.

Functions

Link to this function

send_query(client, query, params \\ %{})

View Source
@spec send_query(pid() | atom(), String.t(), map()) :: {:ok, any()} | {:error, any()}

Sends a State Query call to the server and returns a response.

This function is synchronous and takes two arguments:

  1. (Optional) A process reference. If none given, it defaults to the linked process __MODULE__.
  2. The name of the query to run.
  3. (Optional) Parameters to the query.

Support for all Ledger-state and Network queries.

For Ledger-state queries, only the name of the query is needed. For example, the following function call

StateQuery.send_query(pid, "epoch")

is the same as calling

StateQuery.send_query(pid, "queryLedgerState/epoch")

For Network queries, the prefix "queryNetwork/" is needed. For example:

StateQuery.send_query(pid, "queryNetwork/blockHeight")

Optional parameters are passed as the third argument:

query_name = "utxo"
query_params = %{addresses: [address_1, address_2]}
StateQuery.send_query(pid, query_name, query_params)
Link to this function

start_link(client, opts)

View Source
@spec start_link(module(), start_options :: Keyword.t()) :: GenServer.on_start()

Starts a new State Query process linked to the current process.

This function should not be called directly, but rather via Xogmios.start_state_link/2