Business Applications on Blockchains: Eclipse Scout, Ethereum and web3j

This blog post provides a brief introduction into the blockchain world and shows how to integrate the Ethereum Blockchain with a Java based Business Application. Specifically we describe the implemented "micro"-banking prototype with Eclipse Scout (the business application side), Ethereum (the blockchain) and web3j (a Java library to communicate with Ethereum).

Blockchain, Bitcoin and Ethereum

Blockchain technologies provide a fully decentralized ledger based on peer-to-peer networks. The Blockchain promise is that network participants can rely on this ledger to safely interact with each other without the need of any central authority or trusting each other. This ledger is represented by a chain of blocks (this is where the term blockchain comes from) where each block contains a number of transactions that have taken place between the network participants. A key feature of blockchain technologies is that blocks in the chain cannot be altered in any way. The only way to change the blockchain is adding new blocks.

Bitcoin – created in 2009 by Satoshi Nakamoto (an unknown person or group of persons) - represents the first successful implementation of blockchain technology. Today, Bitcoin represents the gold standard of virtual currencies and enjoys growing popularity and its currency is soaring again. Luckily, Bitcoin has also set the precedent for blockchain technology to be open source. Recommended pointers being: The whitepaper, the code and a technical book (written in Asciidoctor) are nice examples.

Ethereum was originally conceived by Vitalik Buterin and in late 2013 he described its concepts in a whitepaper. The goal of Ethereum is to provide a blockchain platform that also includes a Turing-complete programming language. Using this formal language, smart contracts can be implemented and deployed to the Ethereum network. After deploying such contracts to the network, they are permanent and available worldwide. Enforcing the contract terms and its execution is then handled by the Ethereum network alone. This concept allows such contracts to act independently of any central authority or infrastructure.

All in all, Ethereum can be seen as the young sibling of Bitcoin. Worrying less and having fun trying new things. It does not (yet) have the stability and track record of Bitcoin but with having the smart contract concept included in its protocol Ethereum is fundamentally more powerful than Bitcoin. As in the case of Bitcoin Ethereum is open source and its codebase is developed openly on Github.

Smart Contracts and Business Applications

Smart contracts enable new application scenarios and business services and carry the potential to disrupt business models in many industries such as finance, insurance, public sector, telco, energy or internet of things.

However, blockchain technologies and smart contracts are both young technologies and its opportunities and risks are not yet well understood. Given the current hype and potential of these technologies, “now” is a good time for developers, key players and strategists to start experimenting with blockchain based services and investigating potential applications to capture open opportunities or to avoid negative surprises in the future.

To explore the potential of this technology and to rapidly identify relevant application fields one important step is to check the feasibility of blockchain-based services using proven technologies and frameworks. The combination of Ethereum and Eclipse Scout holds the potential to greatly simplify the development of such business applications and to speed up the time from ideas to working applications.

Eclipse Scout and Business Applications

Based on Java and providing an HTML5 frontend the open source framework Eclipse Scout well meets today’s technology standards and has been proven in production for over a decade. Since 2010, the Scout project is hosted by the Eclipse foundation and meets the foundation’s IP and governance policies that provided the necessary security for mission critical commercial usage.

The Scout framework has been specifically built for business applications with the following three goals in mind.

  • Implementing and maintaining business applications must be efficient.
  • Business applications should be independent of specific technologies.
  • Learning the framework should be painless.

Scout may be used for any type of business applications such as ERP, CRM or medical data storage systems. As Scout is agnostic to the application domain it is also a good fit to build blockchain based business applications.

Ethereum and Java: web3j

For the integration of the Ethereum network with Scout business applications the open source web3j libaray by Conor Svensson proves to be a good fit. Ethereum clients provide a JSON-RPC interface which allows external systems to communicate with the node. The web3j library brings the JSON-RPC of the Ethereum clients into our Java based business application by wrapping the communication including the JSON messages into plain Java objects as shown below.

This perfectly fits our need of our “micro” banking prototype for a clean and comfortable way to interact with the JSON-RPC of the Ethereum clients without having to deal with the raw JSON messages. Based on this approach we can take advantage of the Java type safety and write code to interact with the Ethereum network on a higher abstraction level. This results in readable and maintainable source code, which is particulary important for large business applications.

The web3j library comes with a good documentation and is easy to integrate into a Scout application. It is enough to add its Maven dependency.

Using the web3j library allows to implement many features with a few lines of plain Java code. The example method below shows how to check the balance of a given Ethereum account address.

The only method parameter is the address of the Ethereum account. First we have get the web3j object on which the method ethGetBalance is available. We also have to specify that we want the balance based on the latest block. The request is then send asynchronously to the Ethereum client to obtain a EthGetBalance balance object. Finally, the method returns the balance of the specified address using getBalance on the balance object.

The “micro”-banking prototype

As an exercise to obtain hands-on experience with blockchain technology and smart contracts we decided to extend the Eclipse Scout Contacts application in a first step to a “micro”-banking app that manages personal accounts and can transfer funds between these accounts.

As shown in the screenshot above, the “micro” banking application allows to create new accounts for the managed persons. From the blockchain perspective the account is uniquely defined by it’s address which in turn is represented by a number. This number alone is sufficient to receive funds and to accumulate a balance of Ethers (the Ethereum virtual currency).

The owner of the account must be in possession of both the account address and it’s corresponding private key. A wallet file is then used to safely store the public/private key pair. In this file the private key is encrypted with a password that needs to be kept separate from the wallet file. In order to spend the balance from an account, the account owner needs to sign every transaction for spending money with the account’s private key.

As shown in the second screenshot, our “micro”-banking prototype also allows to create offline transactions that can then be sent to the Ethereum network. In most cases the transaction is then confirmed by the network within a few minutes. The transaction can of course also be verified externally on any Ethereum blockchain explorer site, for example on etherchain.org.

The link between persons and accounts in the “micro” banking application is just added on top to keep track of the relations between persons and Ethereum accounts. The cool thing is that the application does not need to keep track of balances and managing transactions. This is provided by the blockchain.

Please note that the “micro” banking prototype described above is work-in progress. As in the case of a typical Scout application the integration of Ethereum is implemented in the backend only. Should you be interested in the code start with classes Account, Transaction and EthereumService. The code is currently available on a GitHub feature branch of the Eclipse Scout contacts application.

After having implemented and verified the basics of the Ethereum integration in a Scout application the next stage will include working with smart contracts, the Ethereum key feature.

If you want to check out web3j with a minimum of effort you may skip setting up your own Ethereum client and just use the Infura online service as described in the web3j documentation.

To get into Eclipse Scout download the package as described on the Scout homepage and follow the “Hello World” tutorial provided on the same page.

Feedback? Any Thoughts? Please use this forum thread.

Scout Links

Project Home | Forum | Wiki | Twitter | Google+ | Professional Support