What are Ethereum dApps and How to build dApps on Ethereum and NEO

Getting started with dApps

The Blockchain technology, since its inception, has revolutionised the digital world with many new concepts coming to the fore. One such concept is the Ethereum Decentralized Applications, or Dapps. Blockchain has multiple emerging real-world applications – Dapps provide a way to apply the technology and realize its full potential. Let’s learn more about it.

What are dApps?

The blockchain is a distributed ledger technology which enables decentralized storage and access of records. The nodes connected to the blockchain can be associated with a physical property and so, Ethereum has revolutionized the blockchain technology by providing a way to establish simple contracts among the nodes on the blockchain. This can be a piece of code which will be executed when a contract is fulfilled.

The dApps or decentralized applications provide a way for the user to connect to the blockchain and access or perform actions. Ethereum dApps, for example, are the links between your browser/Toshi mobile client and the smart contracts on Blockchain. It is an open-source and decentralized web application that makes access requests to the backend server through API. Data sent and received are stored in the application itself and the business logic occurs through the smart contracts on the Blockchain.

Dapps have been impactful in 2017 and areas that are targeted in coming years are improved Data Ownership Rights, IOT Integration and Enhanced Digital Security. Greater control over the content owners will lie with the creator and an average internet user will be able to make money from their ideas and products. Similarly, this also solves the problem of data transfer for the internet of Things due to the birth of the increased number of data points. Blockchains are supposed to be immutable and have an enhanced security feature, which on the evolution of the Dapps technology is only set to strengthen.

How do you use Dapps?

Now that we know what Dapps is, let’s understand how to use them. Dapps are like traditional web application which run on your browser and simultaneously interact with the Blockchain using technology like ethereum Smart Contracts. So, you need to enable your browser to communicate with the ethereum blockchain layer. Nowadays, there are wallets coming up as browser extensions that do this for you. One such example is MetaMask, which not only serves as a Wallet to store currencies but also allows you to do transactions directly by exposing a javascript SDK.

One of the ways to use dApps is through Toshi Browser, the latter part of the post describes more about the Toshi Platform.

How do you build Dapps?

If you are looking into building Dapps, you might want to get started with Truffle Suite. It offers an easy platform to create, deploy and migrate client application. You will need a client application that integrates your Dapps to Ethereum Smart Contracts. Truffle Suite offers various features that simplify your work of deployment of Smart Contracts and client application. It consists of features like “Truffle boxes” that help to build Applications from scratch and automated testing of contracts. It also supports local version of ethereum blockchain technology that could be used to test your distributed apps locally before you migrate it to the actual blockchain.

You can download Truffle Suite from its official website - (http://truffleframework.com/docs/getting_started/installation)

NodeJS 5.0+, Windows, Linux and Mac OS X are all recommended Operating systems. You would also require running Ethereum Client which supports JSON RPC API. For each OS, instructions are given on their official website.

If you are just planning to write programs that connect to the ethereum blockchain, ethereum provides a very nice open source library called EthereumJ. EthereumJ is a java client library which is a pure Java implementation of the ethereum protocol.

What are smart contracts?

Suppose we have an agreement between two parties to accomplish a particular job, say delivery of physical goods from suppliers to retailers, within a specified timeframe. Now, this agreement is generally enforceable in a court of law. Here, a third party i.e the court serves as an enforcer of the contract.  The main cause of this third party to exist is lack of trust between the people who are participating in the exchange.

By using the blockchain technology with ethereum smart contracts, this third party can be eliminated. Here, smart contracts act as the enforcer of the agreement which is powered by their underlying blockchain technology. Any agreement which is approved by both parties is permanently stored on the blockchain and is instantly verifiable. Since this is public, the legitimacy can be easily verified and they are trackable and irreversible as well.

The Ethereum smart contracts are powered by the Ethereum Virtual Machine. Any computational task can be run on this machine easily by paying its costs to the miners of the network. In this case, that cost is ether. The actual value of ether depends on the instant of time but for now, the actual cost of any transaction is comparatively less and the entire process is definitely improved.

How to debug Smart Contracts?

One of the challenges faced is troubleshooting Smart Contracts when building Dapps. While testing a software program, one logs messages.Here too, you can log messages to the console while running the application to see what is going wrong. For distributed Smart contracts, you can approach the problem with creating and logging a new event and then firing those events from the transaction. With the use of Truffle, you will directly receive the response or you can stream those events directly to the browser using the web3 client. Usually, a transaction does not return any data once processed, so you need to create such events and fire them with the appropriate information. Geth is an Ethereum node that handles all the specific events from the web socket server.

Let’s take a small practical dApp so that you realize the entire concept more clearly.

Download Node.js and install it on your PC. Next, install MetaMask Chrome Extension.

Now, install Truffle using command: npm install -g truffle on the command prompt

Now, create new directory for new project using: mkdir smartapp

Go into the directory by using: cd smartapp

Unbox the react-auth app using: truffle unbox react-auth.

Now test your app on local development console i.e. Ethereum node where contracts can be deployed and executed using the command : truffle develop.

Next, compile and migrate the contracts to deploy them on the test node using commands:

Truffle Compile;

Truffle migrate;

OR

truffle migrate –reset –compile-all

  1. Now run the local server to test the frontend resources, to do this use command: npm run start, this will open up your browser and navigate to localhost:3000.
  2. You need to configure your MetaMask to the locally running test node. Now your application is deployed and running.
  3. Test the UI of your application by signing up and logging into the application.

There you go, your first Dapp is up and running!

Development of Dapps is still in its nascent stage and requires further advancement of controls. With the emergence of blockchain-supported technologies like bitcoin, new pathways were opened for new concepts like Dapps that targeted specific business solutions. For example, 4G Capital, an app that empowers businesses, individuals and markets by providing financial help by use of smart contracts.

The “Toshi Browser”

Toshi/ Source: Google Play Store

Coinbase is developing Toshi browser is an open protocol that consists of a private and secure messaging app, an Ethereum Wallet and browser for Ethereum apps. It is similar to the web browser running on your mobile but a decentralized platform from where you can manage your own funds. Toshi browser uses Signal Protocol for encryption of messages and Ethereum network for global payment. Also, their apps are built on SOFA protocol suitable for integration with financial applications.

It is also thought to be a trusted product as it let users rate apps and users according to the number of transactions over a period of time, so you can be sure about them according to their reputation. Their concept is inspired by WeChat which is driving all financial payments online in China.

As they want to impact the world of the digital financial system, their long-term goals include providing financial services to all the people having access to mobile, make them empowered to build and use Ethereum applications and shift the image of digital currency from just being an investment to payment network and much more.

NEO dApps

NEO founded in 2014 is another platform which enables smart contracts on the blockchain and like Ethereum. The core developers of NEO are based out of China and are aggressively building a full-featured platform which will make it easy for application developers to build dApps on top of NEO platform. There are already some applications built on top of NEO which is used by hundreds of users. NEO according to their website says they believe in building the smart economy by combining digital assets, digital identity and smart contracts.

Though Ethereum has more core developers and application developers in the ecosystem, the NEO community is increasing at a faster pace and it would be interesting to watch which platform will make the dent in dApps.

Please share it if you enjoy the read!

Leave a Reply

Your email address will not be published. Required fields are marked *