Why DApp is the Perfect Solution for your Business?

Reading Time: 4 minutes

The world is changing…Humanity is standing on the brick of the next big Revolution so does the Business World. It is likely to impact every major Business from accounting to Operations. And the shift is already begun. Connectivity is the necessity of every Business. Modern Business must connect to with their customers, suppliers, and partners and in man case, these participants are in different geographical and regulatory boundaries. Proper connectivity allows proper flow of goods and services across the network.

Where Can Blockchain be Used ?

The Retail Industry could advance home sales by quickly verifying finances, would reduce fraud thanks to its encryption, and would offer transparency throughout the entire selling and purchasing process. The different retail industries that Blockchain will affect are real estate agents, home inspectors, closing representatives, real estate appraisers, loan officers, loan processors.

 The banking industry is highly regulated, and the cost of maintenance is very high. Blockchain technology can be used to decrease the cost of these transfers by reducing the need for banks to manually settle transactions. The different area of banking where Blockchain can be used are international payment, capital markets, trade finance, regulatory compliance and audit, money laundering protection, insurance and peer to peer interaction.

Other Industries where Blockchain can be used are financial management, Healthcare, Government Industries and Cybersecurity are a few examples from many.

The Perfect D-App

According to Sandwich Complexity model, think your application as Sandwich, the UI (top bread layer) and the smart contract layer (bottom bread layer) should remain as simple as possible, and when it makes sense complexity and business logic should live in the middle layer (the meat of the sandwich).

  • Keep Smart Contract layer (bottom) as simple as possible.
  • Keep the presentation layer (top) as simple as possible.
  • Keep complexity in the middle of the application.

Layers Of Blockchain Solution:-

Presentation Layer:-

No special technical knowledge is needed to make Front End for Decentralised Application. User Experience should seek to make users understand and value any new or different feature that blockchain provides.

Blockchain Layer:-

This is the most crucial layer for any Decentralised Application. In this layer smart contracts exist. So basically Smart Contract is a Self-executing contract between different parties. The code and the agreements contained therein exist across a distributed, decentralized blockchain network. The code controls the execution, and transactions are trackable and irreversible. There are multiple languages to build smart contract namely Solidity, AML, BOScoin, DAML. But in this blog, we talk more about DAML.


What makes DAML better from other languages is that the contract is of private type because shortcoming of public type is that every node on the platform can view data that is present in smart contracts which prevents the complete adoption of enterprise blockchain. DAML is best for the Enterprise Blockchain. It seems to achieve the excellence of Blockchain and its open-source which could be used to write distributed applications quickly, concisely and correctly. Notably, the design of the system is in a way that machines and humans can understand the information included in the contract.

Middle (Interface) Layer:-

Middle Layer also plays an important role in DApp as it communicates to and from Blockchain Layer. This layer contains validation and Exceptional Handling Code and all communication to and from the Blockchain Layer is Bytecode. In this layer, we also connect Microservices. There are a lot of Languages for Middle Layer like Java, JavaScript, Scala and many other languages. But in this Blog, we are going to talk about Scala.

Why Scala ?

Scala is an exciting programming language that has been gaining popularity across the industry. Some say it may even replace Java. The Scala programming language combines functional programming and object-oriented programming into one language. The name is an acronym from Scalable Language. Scala was designed to improve upon Java, so you can call Java methods, inherit from Java classes, and more. In fact, Java libraries can even be incorporated in Scala code, and Scala is compiled in Java bytecode, so it is executed in the JVM. Scala gained lot of popularity as it works great with Microservice.
   And it works great with DAML as Blockchain layer as DAML provides Scala Binding which is the client implementation of Ledger API, where Ledger API helps to interacts with Ledger through gRPC calls. The Scala bindings library lets you write applications that connect to Blockchain Layer. For this, it uses two main components:

  • Scala Codegen
  • Akka Stream Based API

Scala Codegen is used to generate Scala classes from DAML models. DAML Models hold templates of Contracts. The generated Scala code provides a type-safe way of creating contracts (CreateCommand) and exercising contract choices (ExerciseCommand). While Akka Stream-based API used to send commands to the ledger and receive transactions back. 

Getting Started with Scala Binding

To use the Scala bindings, set up the following dependencies in your project. If you are using sbt build tool, then add it in build.sbt file :-

lazy val codeGenDependencies = Seq(
“com.daml.scala” %% “bindings” % daSdkVersion
lazy val applicationDependencies = Seq(
“com.daml.scala” %% “bindings-akka” % daSdkVersion,

If you are new to DAML, than first visit Getting started with building Templates for introduction to DAML and clone this Project for better understanding as following code is based on it. Now to generate Scala Code from DAML model run:-

$daml codegen scala

To create a Scala class representing a Contact contract first, you need to import the following things:-

import com.digitalasset.ledger.client.binding.{Primitive => P}
import com.knoldus.{Iou => M}

To create Party variable in scala :-

private val firstParty = P.Party("Alice")

Add follwing to create Instance of Template:-

val iou = M.Contact(                                                                                           
  owner = firstParty,
  telephone = "12345"

To send a CreateCommand (keep in mind the following code snippet is part of the Scala for comprehension expression):

createCmd = iou.create                                                                                _ <- clientUtil.submitCommand(firstParty, issuerWorkflowId, createCmd)
_ = logger.info(s"$firstParty created Contact: $iou")
_ = logger.info(s"$firstParty sent create command: $createCmd")