2. erste Schritte

In diesem Guide werden wir ein einfaches Iroha-Netzwerk erstellen, starten, einige Transaktionen erstellen und die in den Ledger geschriebenen Daten kontrollieren. Um dies so einfach wie möglich zu gestalten nutzen wir Docker.

Bemerkung

Ledger is the synonym for a blockchain, and Hyperledger Iroha is known also as Distributed Ledger Technology framework — which in essence is the same as „blockchain framework“. You can check the rest of terminology used in the Kernkonzepte section.

2.1. Vorraussetzungen

For this guide, you need a machine with Docker installed. You can read how to install it on a Docker’s website.

Bemerkung

Of course you can build Iroha from scratch, modify its code and launch a customized node! If you are curious how to do that — you can check Building Iroha section. In this guide we will use a standard distribution of Iroha available as a docker image.

2.2. Iroha-Node starten

2.2.1. Docker Netzwerk kreiren

Iroha benötigt eine „PostgreSQL“ Datenbank. Lass‘ uns mit der Erstellung eines Docker-Netzwerkes starten, damit Container für Postgres und Iroha im selben virtuellen Netzwerk laufen und miteinander erfolgreichen kommunizieren. In diesem Guide werden wir es „iroha-network“ nennen, du kannst aber jeden Namen benutzen. Schreibe in deinem Terminal folgenden Befehl:

docker network create iroha-network

2.2.2. PostgreSQL Container starten

Jetzt müssen wir „PostgreSQL“ in einem Container laufen lassen, mit dem vorher erstellten Netzwerk verbinden und die Ports für die Kommunikation öffnen:

docker run --name some-postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=mysecretpassword \
-p 5432:5432 \
--network=iroha-network \
-d postgres:9.5 \
-c 'max_prepared_transactions=100'

Bemerkung

If you already have Postgres running on a host system on default port (5432), then you should pick another free port that will be occupied. For example, 5433: -p 5433:5432

2.2.3. Erstellung des Blockstores

Before we run Iroha container, we may create a persistent volume to store files, storing blocks for the chain. It is done via the following command:

docker volume create blockstore

2.2.4. Preparing the configuration files

Bemerkung

To keep things simple, in this guide we will create a network containing only a single node. To understand how to run several peers, follow Deploying Iroha

Now we need to configure our Iroha network. This includes creating a configuration file, generating keypairs for a users, writing a list of peers and creating a genesis block.

Don’t be scared away — we have prepared an example configuration for this guide, so you can start testing Iroha node now. In order to get those files, you need to clone the Iroha repository from Github or copy them manually (cloning is faster, though).

git clone -b master https://github.com/hyperledger/iroha --depth=1

Hinweis

--depth=1 option allows us to download only the latest commit and save some time and bandwidth. If you want to get a full commit history, you can omit this option.

There is a guide on how to set up the parameters and tune them with respect to your environment and load expectations: Die Konfiguration. We don’t need to do this at the moment.

2.2.5. Iroha-Container starten

We are almost ready to launch our Iroha container. You just need to know the path to configuration files (from the step above).

Let’s start Iroha node in Docker container with the following command:

docker run --name iroha \
-d \
-p 50051:50051 \
-v $(pwd)/iroha/example:/opt/iroha_data \
-v blockstore:/tmp/block_store \
--network=iroha-network \
-e KEY='node0' \
hyperledger/iroha:latest

If you started the node successfully you would see the container id in the same console where you started the container.

Let’s look in details what this command does:

  • docker run --name iroha \ creates a container iroha
  • -d \ runs container in the background
  • -p 50051:50051 \ exposes a port for communication with a client (we will use this later)
  • -v YOUR_PATH_TO_CONF_FILES:/opt/iroha_data \ is how we pass our configuration files to docker container. The example directory is indicated in the code block above.
  • -v blockstore:/tmp/block_store \ adds persistent block storage (Docker volume) to a container, so that the blocks aren’t lost after we stop the container
  • --network=iroha-network \ adds our container to previously created iroha-network for communication with PostgreSQL server
  • -e KEY='node0' \ - here please indicate a key name that will identify the node allowing it to confirm operations. The keys should be placed in the directory with configuration files mentioned above.
  • hyperledger/iroha:latest is a reference to the image pointing to the latest release

You can check the logs by running docker logs iroha.

You can try using one of sample guides in order to send some transactions to Iroha and query its state.