Blockchain Development Made Easy with Open Source Tools

0
682
Advertisement

The blockchain has become a full-fledged Internet technology, and its popularity has been enhanced by the runaway success of Bitcoin. Open source tools make it easy to deploy blockchains for individual needs. Let’s see how.

According to a recent report released by LinkedIn, blockchain developer jobs will see growth to the order of 33x this year (https://economicgraph.linkedin.com/research/linkedin-2018-emerging-jobs-report). Blockchain picked up pace when the Bitcoin price skyrocketed. Actually, blockchain is the underlying technology for any cryptocurrency. In brief, blockchain is a distributed immutable ledger. The ledger can be a public one like Bitcoin or a permissioned one such as Hyperledger.

Based on our experience, we would like to discuss some of the open source tools for blockchain development, which we hope will be of great help in easing the application development process.
In our previous article, ‘Blockchain in Healthcare’ we covered the basics of blockchain and how it can revolutionise healthcare (https://opensourceforu.com/2019/02/how-the-blockchain-can-add-transparency-to-healthcare/).

Figure 1: Solidity – A contract oriented high level language
Figure 2: NodeJS – Non-blocking and event driven

In this article, we begin with explaining the languages for application development and the integrated development environment (IDE) needed for the task. We will also discuss popular open source frameworks for blockchain application development such as Testnet, Drizzle, IPFS and CouchDB.

Advertisement

Languages
For blockchain developers, other than deciding on the architecture for the network, the most interesting and important task is to write the smart contracts (or chaincodes). Smart contracts serve the same purpose as legal contracts in the real world — one can query them and add a state to the blockchain.

A lot of users interact with the smart contract at the same time. Therefore, it should be written in a language that is non-blocking and asynchronous.

Some of the most popular languages used for writing contracts are listed below.

Solidity: This is an object-oriented language used to write smart contracts. It is a lot like JavaScript, which makes it easy to understand. You can find more details about it at https://solidity.readthedocs.io/en/v0.5.4/style-guide.html.

Go: Golang, a language developed by Google, is used in Hyperledger to write chaincodes. It’s a language that takes advantage of modern hardware architecture. It also has native garbage collection that removes the need for developers to do their own memory management. Further details can be found in the Golang home page at https://golang.org/.

NodeJS: This is an asynchronous language, which is used for application code as well as for smart contracts.

After figuring out the language, we need a development environment. Development environments come with a lot of configuration that will help throughout the process of application development.

Figure 3: Remix browser
Figure 4: TronStudio

Integrated development environments (IDE)
Often, we need to develop a proof-of-concept (POC) before starting with the actual application. Here, let’s concentrate only on smart contracts and leave out the other development aspects like testing, debugging, integration, etc, that are handled by IDEs.

Some popular open source IDEs are listed below.
Remix: This open source tool can be accessed from a browser or installed in a local system. It is written in JavaScript. It can be used to write, deploy and then run smart contracts for the Ethereum network.

Features
a) It provides features like testing, debugging and deploying of smart contacts.
b) It also calculates the gas to be used for carrying out a transaction. Gas is a unit that measures the computational effort required to carry out a certain operation. You can find out more about gas at https://blockgeeks.com/guides/thereum-gas-step-by-step-guide/.

Figure 3 shows its features such as analysis, compilation, testing and debugging.
TronStudio: This is a comprehensive IDE that runs the code for TRON Virtual Machine (TVM). It has the features to create a private local environment for developers to test their smart contracts before deployment.

Features
a) It supports Solidity as a language for writing smart contracts.
b) It provides the same features as Remix but is not accessible on the browser, at present.
Figure 4 provides compilation, running and debugging in TronStudio.

While developing dApps (distributed applications) we need to configure the nodes, peers, the database, and ordering service (order synchroniser for transactions), and then connect smart contracts with the blockchain. Setting up the network architecture manually for the application may be a hectic task, which is where frameworks are useful. We mean hectic in the sense that there are various steps involved like generating CA certificates, installing chaincodes on peer machines, and specifying the channel ID configurations which are needed to set up and run the network.

Frameworks come with default configurations and are handled using docker-compose.yaml files, which avoids manual configuration.

Figure 5: Composer playground
Figure 6: Gnache Testet shows transactions, balances and hash addresses

Frameworks
The problem that most people face when trying to start learning something new is, where to start.
Every blockchain project has many demo applications which come with tools and libraries in a single, easily downloadable package. It already has a basic client application GUI with which users are able to interact with distributed stored smart contracts. It also has a database and Testnet configured for direct use. One can either just get familiar with the demo application, or modify it and try it for learning purposes.

Truffle boxes: This is the most popular of templates (called boilerplates) for setting up the initial structure of your dApps. Truffle boxes contain modules that take care of the front-end (drizzle) and are connected to smart contracts, testing and deployment with an access to the blockchain framework. More details are available at https://truffleframework.com/boxes.

Hyperledger Umbrella: This is an open source project under the Linux Foundation and IBM. It consists of a lot of frameworks, the popular ones being Fabric, Composer and Sawtooth. These are mainly customised blockchains for enterprise use where data needs to be private, involves a lot of different members and requires transparency between enterprises.

Fabric: This has two broad aspects — infrastructure and application. It is modular in architecture and configures the required modules as and when required. The infrastructure consists of peers, endorsing peers, an ordering service and others such as MSP (membership service provider), while application components include the smart contract and the client side.

Figure 7: Drizzle – A modular front-end module configured to interact with smart contracts
Figure 8: Decentralised hash based storage

Features
a) It is capable of making channels inside a network where only a member of that channel can access the related data. A member can also be a participant in two channels, depending on business needs.
b) It has components like a membership service and consensus as plug-and-play components.
c) It is very flexible with respect to the architecture of the network — organisations, peers belonging to organisations, etc.
Composer: This is an abstract application level framework to build and run blockchain applications on top of Hyperledger Fabric. It takes hours instead of weeks to develop an application based on the proof-of-concept.

Features
a) It allows users to define the data model (.cto files), business logic and access control lists for an application that can be deployed and executed inside Fabric.
b) It has a composer playground, which allows users to run composers along with setting up the local blockchain network. You can read more about this at https://hyperledger.github.io/.composer/latest/.
Figure 5 shows an abstract layer over Fabric that lets you make a blockchain model and run it on a browser.
Testnet: This can quickly fire up a personal blockchain which can be used to run tests, execute commands and inspect the state while controlling the operation of the chain.
Gnache: Previously known as TestRPC, Gnache provides a local blockchain for development purposes. It comes with an interface with which you can see and interact with your private blockchain. It provides information about the transaction count, balances, etc.

Features
a) We can run tests and know about the internal state of the network using Gnache.
b) It has the output log and other internal blockchain information, including responses and other debugging information. More can be read at https://truffleframework.com/gnache.

Frontends
Drizzle: This is a Front-ends library collection that is used for making dApps user interfaces. It comes with a predefined configuration, which takes care of synchronising smart contract data. Also, it comes with React components for commonly used functions like generating an input form for contracts. Further details can be read at https://truffleframework.com/drizzle.

Features
a) Its architecture is completely modular and can be modified according to the need.
b) As of now Drizzle-React is available for direct use but making it Drizzle-React is not difficult because of the architecture.

Docker images: All major blockchain frameworks have their Docker image available at hub.docker.com.

Storage
IPFS (Interplanetary File System): As the name suggests, it can help you store and create Web3 storage. It uses decentralised storage and links every file using a hash instead of an address reference as is currently used by our standard Internet system. Hashes generated can be stored into the blockchain instead of storing the whole file. It can be used with any blockchain network. A detailed explanation can be found at http://www.ipfs.io.

CouchDB: This is a key-value state database embedded in the peer process. It is an alternative to levelDB (also, a key pair database) for a state database in Hyperledger Fabric. Additionally, it lets you query state database in JSON format, querying by a range or composite keys for multiple parameters. It syncs data between server clusters and mobile phones, Web apps and others, enabling a complete offline-first user experience. CouchDB is internally fault-tolerant and a single problem does not cascade to affect the entire database, but remains in an isolated request.

Figure 9: CouchDB

BaaS: Blockchain-as-a-Service
As blockchain has gone mainstream, tech giants have released their own versions of it as a service. We can add the needed members and everything else is handled by the service itself. These services are flexible and can be integrated with existing systems using REST APIs.

Microsoft Azure: This created the so called BaaS or Blockchain-as-a-Service, a useful tool for developers to build dApps in a safe and cheaper environment — one that supports several chains, including MultiChain, Eris, Storj, and Augur. BaaS was created mainly to enable the backend capabilities needed by blockchain solutions. On Azure, a blockchain can be launched with just a few clicks, rather than by setting up your own. More information is available at https://azure.microsoft.com/en-in/features/blockchain-workbench/.

AWS: This is a template provided by Amazon Web Services to create and deploy blockchain networks very fast and in an easy manner (https://aws.amazon.com/blockchain/)

Advertisement

LEAVE A REPLY

Please enter your comment!
Please enter your name here