Getting started with IOTA

In the previous post we took a first glance at IOTA ledger. Although the plans are great, currently the project is in its incubation phase, with the majority of the most attractive features not yet ready to use. But this shouldn’t stop us from playing with what we already have today.

Before we dig into the code, we need to get connected to one of the two IOTA networks. The “proper” network is called mainnet and there is also a slightly more relaxed one called testnet. As the names suggest, the latter is for test purposes. Each network consists of the multiple nodes that are run by the community. In order to join the network, we either need to run our own node or to connect to the existing node using its public API.

Is node a node?

If we’re tech savvy enough and we have decided to become an active part of the IOTA network, we need to have our node up and running. IOTA’s terminology avoids using “node” name for what they offer now. The only software that is able to run as a part of the network is called “IOTA Reference Implementation” (IRI) – my guess is that it is intended to suggest clearly that the project is still in its infancy and everything might change over time.

IRI is written in Java and is publicly available on GitHub as GPL-licenced open source. Requiring a full Java JRE to run a node is probably one of the reasons IOTA is not yet feasible for real IoT usage. We can choose to run it either from a JAR file provided or – which sounds more appealing to me – using Docker image.

Let’s roll

To build and run the Docker image, type the following:

docker run -d --name iota-node \
  -p 14265:14265 -p 14777:14777/udp -p 15777:15777 \
  -v ~/iota.ini:/iri/iota.ini iotaledger/iri:v1.4.0

We’re creating a container named iota-node for an easy future access. With -p options we’re exposing three custom network ports for external communication. And with -v we’re passing a path to our node’s configuration file that should look as follows:

[IRI]
PORT = 14265
UDP_RECEIVER_PORT = 14777
TCP_RECEIVER_PORT = 15777
NEIGHBORS = [space-separated list of neighbors]
IXI_DIR = ixi
HEADLESS = true
DEBUG = true
DB_PATH = mainnetdb

Here we have the communication ports specified again. They deserve an explanation as its purposes and usage are not obvious and the official docs are not helpful.

The first one – named cryptically PORT – is used to expose our node’s HTTP API. It is useful to configure, orchestrate and monitor our node, but it should not necessarily be exposed to the public internet. We should leave it available from inside the Docker container just for us, but it is not necessary to expose it on our external firewall.

UDP_RECEIVER_PORT and TCP_RECEIVER_PORT are ports that need to be exposed via the firewall – so ensure your router or ISP allows you to configure public traffic over these ports to reach your node. IRI uses UDP by default with TCP fallback – technically, only one of these channels need to be reachable. UDP adds less overhead but TCP in some cases is easier to set up and debug.

Get along with your neighbors

We now have a stranded process running in the void. It’s time to find other nodes we can connect to and sync the state of the Tangle with it. These other nodes are called “neighbors” and we need to maintain a two-way channel between us and our neighbors. As of today, the only way to get some neighbors is to ask the friendly people on #nodesharing IOTA’s Slack channel for a way in. When asked during the European’s daytime, I got some responses in less than an hour.

When you’re already befriended with other nodes owners, you need to give them the publicly available address of your host – most probably looking like udp://12.23.34.45:14777. Note we’re specifying the UDP protocol here and using a corresponding receiver port from our INI file. Our neighbors should give us their addresses, also for UDP protocol (if we decide to use UDP, that is – for TCP, both sides should use TCP protocol and ports, obviously).

To add a neighbor, include its address in your iota.ini file, in NEIGHBORS field, as a space-separated list and restart your node. Alternatively, you can use your node’s HTTP API method to add a neighbor dynamically.

After this is done, try calling getNeighbors to see what’s going on. If everything goes right, the number of all transactions should grow pretty quickly. Now just go for a long lunch (possibly including a dinner) and when you’re back, you’ll be in sync with the network, being a part of IOTA ecosystem. Hooray!

Light Node

There is also the wallet client app (also called “light node”), but its use is restricted to token trading. It requires a connection to the existing node’s HTTP API (this one exposed via port defined in PORT – 14265 in my example). But we’re geeks, we care about tech stuff more than about trading ?.

Speaking of the node’s HTTP API again. If it’s there, we might also use it directly on our own, right? Sure we can. Stay tuned for the next post in the series where we’ll submit a Hello World transaction to IOTA from a Node.JS application.

A post by Adam Bar

IOTA – a new kid in the cryptocurrency town

At Baltic Data Science, we always try to keep focus on the bleeding-edge technologies and innovations. We are especially interested in cryptocurrencies and its prospective wide usage in the industry, not only as a payment method. We already have some experience with Ethereum and Hyperledger as a Blockchain-based app platform, so we were curious what can IOTA offer.

IOTA’s marketing offerings are very prominent. It calls itself “a backbone of IoT” and promises scalability, decentralization, modularity and the lack of transactional fees. Its primary goal is to enable the “Economy of Things” – an environment in which the IoT devices might conduct secure, verifiable and reliable automated transactions for even the smallest amounts. It is not feasible with other cryptocurrency-based technologies because of the transaction fees that would be possibly larger than the amount exchanged.

What IOTA is (or plans to be)?

First of all, technically speaking, contrary to Bitcoin, Ethereum or Hyperledger, it is not a blockchain-basedsolution, because transactions do not require blocks to be formed nor do they create a single chain of blocks. Instead, each transaction is a separate node in the tree-shaped graph of transactions. Every transaction references two earlier transactions that exist in the tree, confirming its validity (by verifying its proof-of-work). This directed tree-shaped graph in IOTA is called the Tangle.

This way, at least theoretically, the whole system is self-validating and the approval process is decoupled from any authority and decentralized. It is also a way to get rid of the transaction fees – all the nodes participating in the network have the incentive to verify proof-of-works of other transactions because it is required in order to submit own transactions to the network.

Scalability, the next major promise of IOTA, is theoretically guaranteed by the fact that it is not required for the node to know the state of the whole Tangle tree – the tree can grow asynchronously in many directions. The assumption is that the separate branches will be eventually “entangled” together and cross-validated by the future transactions. This idea allows nodes to work in a non-fully synced state – this is especially useful in the context of IoT devices that might encounter being offline for a myriad of reasons.

The current state of affairs

Let’s leave the marketing buzz from the landing page and check how all these promises work in today’s reality. The project itself is quite young – the initial commit of the node implementation is not even a year old (Oct 2016). And while the project is really dynamic, it is still in the very early phase. If you count on any detailed reference or deep-dive instructions – you will be disappointed. All you can find is a theoretical academic whitepaper, coarse and partial definitions of terms, API reference and a vibrant Slack community that serves as an announcement board and the only way to have the node connected to the network. For all the rest you need to either dig through the source code or count on the community on Slack to help you.

It turns out that the other theoretical goals are also far from being met in practice.

Decentralization

The pure IOTA Tangle is vulnerable to the attack that enables verification of invalid transactions by generating large enough sub-branch of the tree consisting of fake transactions so that the branch overweights the original, legitimate transactions branch, making it orphaned and leading to the approval of the double-spending transaction.

As of October 2017, there is a single designated node in the IOTA network, called Coordinator, that ensures the consistent state of the ledger, re-validating all the transactions and periodically generating a “Milestone mark” that is intended to indicate the “correct” branch of the Tangle tree. A Milestone is a special transaction, issued by the designated Coordinator node, which marks all the transactions it directly or indirectly approves as trusted.

The existence of Coordinator makes IOTA not fully decentralized by now and prevents from having a private ledger networks, because its address is hardcoded into the IRI (reference node implementation) and its source is not disclosed.

It is said that the existence of the Coordinator is a temporary measure, until the protocol stabilizes and the network gets a certain size making it unfeasible to take over, but no due date is given.

IoT app platform

The idea of the IOTA system is to be possible to run it directly on IoT devices. It is not yet possible to run the full node on Raspberry Pi, though. However, it should be possible to run the thin client that connects to the external node.

What is important, IOTA cannot serve as an app platform as long as there’s no Smart Contract functionality there. It is planned, but it doesn’t seem to be reasonable to expect it soon.

What next?

Even if the number of ToD’s on the IOTA team’s list is long, there are definitely some parts that can be used even today.

In our next post, we’ll look into the ways we can interact with the Tangle, even in its current state of maturity.

A post by Adam Bar.