2. 시작하기

In this guide, we will create a very basic Iroha network, launch it, create a couple of transactions, and check the data written in the ledger. To keep things simple, we will use Docker.

주석

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 주요 개념 section.

2.1. Prerequisites

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

주석

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 노드 시작하기

2.2.1. 도커 네트워크 생성하기

Iroha는 PostgreSQL 데이터베이스를 필요로 합니다. 우선 도커 네트워크를 생성하여 Postgres와 Iroha가 같은 가상 네트워크에서 실행되어 성공적으로 통신할 수 있게 합니다. 이 가이드에서는 방금 생성한 가상 네트워크를 ``Iroha-network``라고 부를 것이지만 원하는 이름으로 설정해도 됩니다. 터미널을 열어 다음 커맨드를 입력하세요.

docker network create iroha-network

2.2.2. PostgreSQL 컨테이너 시작하기

Now we need to run PostgreSQL in a container, attach it to the network you have created before, and expose ports for communication:

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'

주석

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. 블록스토어 만들기

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

주석

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 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

힌트

--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: 설정. We don't need to do this at the moment.

2.2.5. Iroha 컨테이너 시작하기

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.