Skip to content

Commit be743db

Browse files
authored
Publish v0.2 (#32)
* Updates for v0.2.0
1 parent d1f58ee commit be743db

File tree

8 files changed

+169
-156
lines changed

8 files changed

+169
-156
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [v0.2.0](https://github.com/wowica/xander/releases/tag/v0.2.0) (2025-05-08)
9+
10+
### Added
11+
12+
- Support for TxSubmission mini-protocol.
13+
- Integration tests on CI using Yaci DevKit.
14+
815
## [v0.1.1](https://github.com/wowica/xander/releases/tag/v0.1.1) (2025-02-19)
916

1017
### Fixed

README.md

Lines changed: 160 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
![CI Status](https://github.com/wowica/xander/actions/workflows/ci.yml/badge.svg)
44
[![Version](https://img.shields.io/hexpm/v/xander.svg)](https://hex.pm/packages/xander)
55

6-
Elixir client for Cardano's Ouroboros networking protocol.
6+
Elixir client for Cardano's Ouroboros networking protocol. This library can be used to build Elixir applications that connect to a Cardano node using the Node-to-Client protocol.
77

8-
⚠️ This project is under active development. For a more stable solution to connect to a Cardano node using Elixir, see [Xogmios](https://github.com/wowica/xogmios).
8+
⚠️ This project is under active development. See [Xogmios](https://github.com/wowica/xogmios) for a more stable solution to connect to a Cardano node through [Ogmios](https://ogmios.dev/).
99

1010
## Mini-Protocols currently supported by this library:
1111

@@ -23,7 +23,7 @@ Below is an example of how to connect to a Cardano node and run a query that ret
2323

2424
```elixir
2525
$ iex
26-
> Mix.install([{:xander, "~> 0.1.0"}])
26+
> Mix.install([{:xander, "~> 0.2.0"}])
2727
> # Must be a valid Unix socket path
2828
> # to a fully synced Cardano node
2929
> socket_path = "/path/to/cardano-node.socket"
@@ -44,6 +44,160 @@ $ iex
4444
For a more detailed description of different ways to use this library, read the following sections:
4545

4646

47-
1. [Running queries via Docker](docs/running-via-docker.md)
48-
2. [Running queries with native Elixir install](docs/running-natively.md)
49-
3. [Submitting transactions](docs/submitting-tx.md)
47+
<details>
48+
<summary><i>Running Queries via Docker</i></summary>
49+
50+
## Running Queries via Docker
51+
52+
In order to run queries via Docker, you need to build the image first:
53+
54+
```
55+
docker build -t xander .
56+
```
57+
58+
With the image built, you can now connect to either a local Cardano node via a UNIX socket or to a node at Demeter.run.
59+
60+
#### 1. Connecting via a local UNIX socket
61+
62+
This assumes you have access to a fully synced Cardano node.
63+
64+
🚨 **Note:** Socket files mapped via socat/ssh tunnels **DO NOT WORK** when using containers on OS X.
65+
66+
Run the previously built Docker image with the `-v` argument, which mounts the path of your local socket path to
67+
the container's default socket path (`/tmp/cardano-node.socket`):
68+
69+
```
70+
docker run --rm \
71+
-v /your/local/node.socket:/tmp/cardano-node.socket \
72+
xander elixir run_queries.exs
73+
```
74+
75+
#### 2. Connecting to a node at Demeter.run
76+
77+
The demo application can connect to a Cardano node at [Demeter.run](https://demeter.run/) 🪄
78+
79+
First, create a Node on Demeter and grab the Node's URL.
80+
81+
Then, run the Docker image with the `DEMETER_URL` environment variable set to your Node's URL:
82+
83+
```bash
84+
docker run --rm \
85+
-e DEMETER_URL=https://your-node-at.demeter.run \
86+
xander elixir run_with_demeter.exs
87+
```
88+
</details>
89+
90+
<details>
91+
<summary><i>Running Queries with native Elixir install</i></summary>
92+
93+
## Running Queries with native Elixir install
94+
95+
For those with Elixir already installed, simply run the commands below:
96+
97+
```
98+
# Must set a local unix socket
99+
elixir run_queries.exs
100+
101+
# Must set a Demeter URL
102+
elixir run_queries_with_demeter.exs
103+
```
104+
105+
More information on connection below:
106+
107+
#### a) Connecting via local UNIX socket
108+
109+
Run the following command using your own Cardano node's socket path:
110+
111+
```bash
112+
CARDANO_NODE_PATH=/your/cardano/node.socket elixir run_queries.exs
113+
```
114+
115+
##### Setting up Unix socket mapping (optional when no direct access to Cardano node)
116+
117+
This is useful if you want to run the application on a server different from your Cardano node.
118+
119+
🚨 **Note:** Socket files mapped via socat/ssh tunnels **DO NOT WORK** when using containers on OS X.
120+
121+
1. Run socat on the remote server with the following command:
122+
123+
```bash
124+
socat TCP-LISTEN:3002,reuseaddr,fork UNIX-CONNECT:/home/cardano_node/socket/node.socket
125+
```
126+
127+
2. Run socat on the local machine with the following command:
128+
129+
```bash
130+
socat UNIX-LISTEN:/tmp/cardano_node.socket,reuseaddr,fork TCP:localhost:3002
131+
```
132+
133+
3. Start an SSH tunnel from the local machine to the remote server with the following command:
134+
135+
```bash
136+
ssh -N -L 3002:localhost:3002 user@remote-server-ip
137+
```
138+
139+
4. Run the example script:
140+
141+
```bash
142+
CARDANO_NODE_PATH=/tmp/cardano_node.socket elixir run.exs
143+
```
144+
145+
#### b) Connecting via Demeter.run
146+
147+
To connect to a node at Demeter.run, set `DEMETER_URL` to your Node Demeter URL.
148+
149+
```bash
150+
DEMETER_URL=https://your-node-at.demeter.run elixir run_with_demeter.exs
151+
```
152+
</details>
153+
154+
<details>
155+
<summary><i>Submitting Transactions</i></summary>
156+
157+
## Submitting Transactions
158+
159+
⚠️ This project does not provide off-chain transaction functionality such as building and signing of transactions.
160+
161+
In order to submit transactions via Xander, you can either run the `submit_tx.exs` script directly or use Docker.
162+
163+
164+
## Running the script
165+
166+
This assumes you have Elixir installed. In order to run the script directly, follow the steps below:
167+
168+
1. Get ahold of the CBOR hex of a valid signed transaction (not covered by this library)
169+
2. Populate the environment variable `CARDANO_NODE_SOCKET_PATH` with a socket file for a fully synced Cardano node.
170+
3. Ensure the `Config.default_config!` function call matches the network being used:
171+
- `Config.default_config!(socket_path)` defaults to Mainnet
172+
- `Config.default_config!(socket_path, :preview)` for Preview network
173+
4. Run `elixir submit_tx.exs <transaction-CBOR-hex>` providing the CBOR hex as its single argument.
174+
175+
A successful submission should return the transaction ID. This ID can be used to check the status of the transaction on any Cardano blockchain explorer.
176+
177+
## Using Docker
178+
179+
This assumes you have Docker installed. No Elixir installation is required.
180+
181+
1. First, build the image:
182+
183+
```
184+
docker build -t xander .
185+
```
186+
187+
2. Ensure the `Config.default_config!` function inside the `submit_tx.exs` file matches the network being used:
188+
- `Config.default_config!(socket_path)` defaults to Mainnet
189+
- `Config.default_config!(socket_path, :preview)` for Preview network
190+
191+
3. Get ahold of the CBOR hex of a valid signed transaction (not covered by this library)
192+
193+
Run the previously built Docker image with the `-v` argument, which mounts the path of your local socket path to
194+
the container's default socket path (`/tmp/cardano-node-preview.socket`):
195+
196+
```
197+
docker run --rm \
198+
-v /your/local/preview-node.socket:/tmp/cardano-node-preview.socket \
199+
xander elixir submit_tx.exs <transaction-CBOR-hex>
200+
```
201+
202+
A successful submission should return the transaction ID. This ID can be used to check the status of the transaction on any Cardano blockchain explorer.
203+
</details>

docs/running-natively.md

Lines changed: 0 additions & 62 deletions
This file was deleted.

docs/running-via-docker.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

docs/submitting-tx.md

Lines changed: 0 additions & 44 deletions
This file was deleted.

lib/transaction/hash.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule Xander.Transaction.Hash do
66
require Logger
77

88
@doc """
9-
Extracts a transaction ID from a transaction CBOR hex
9+
Extracts a transaction ID from a transaction CBOR hex.
1010
Returns the transaction ID as a string, or nil if there's an error.
1111
1212
## Examples

lib/xander.ex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
defmodule Xander do
22
@moduledoc false
3-
4-
def get_current_era do
5-
Xander.Query.run(:get_current_era)
6-
end
73
end

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule Xander.MixProject do
33

44
@description "An Elixir library for communicating with a Cardano node"
55
@source_url "https://github.com/wowica/xander"
6-
@version "0.1.1"
6+
@version "0.2.0"
77

88
def project do
99
[

0 commit comments

Comments
 (0)