The first use of the Blockchain was indeed for cryptocurrency, but Satoshi Nakamoto foresaw a wider range of applications. The emergence of Ethereum has changed the way blockchain is perceived. Ethereum is the blockchain made for the development of decentralized applications DApps (Decentralized Applications), other blockchains are made for making cryptocurrencies with more advanced token concepts.
Do you want to develop a Blockchain project?
- Developing decentralized DApps is like developing smart contracts
- Developing decentralized DApps is like developing smart contracts because an application on Ethereum is a smart contract.
There is today an ecosystem of Dapps development with various programming languages, the most popular of which is Solidity. It is an object-oriented language allowing the writing of Smart Contract via a rather simple syntax.
In Solidity you can find
- primitive types,
- function definition,
- a notion of inheritance,
- control structures
- and the possibility to define data structures.
How to deploy a smart contract on a blockchain?
Each smart contract has a data zone that it can manage. It is a kind of hash table specific and private to this smart contract which will use it to store a certain amount of information.
Once the source code is ready, to deploy on the blockchain, we will start by compiling it. Today, there are compilers available on the internet.
This compiler will create two things: binary code that will run on the VM, it’s not a VM in the Java sense, it’s rather a program that executes compiled bytecode and next to it what is called an ABI (application binary interface) which in cribes the interface of the contract and the methods that can be called by other smart contracts or by applications. When we deploy a contract, we receive a new address on the blockchain which is the address of the smart contract.
What are the specificities of the Ethereum blockchain?
Unlike all other blockchains where there is only one type of address, in Ethereum there are two types of addresses. You can’t see any difference when you look at the address structure. But when you look at the blockchain, you can see what is on this address
- either an account that will be created by an Ethereum user,
- or a smart contract to which we can send messages.
When it is a smart contract, I send transactions that will launch an execution on the smart contract and when it is a classic account, we can send Ether.
Which integrated development environment (or IDE) to use to develop DApps?
Today we are in the infancy of blockchains and especially of Ethereum. IDEs (integrated development environments) are quite poor. To develop Smart Contracts, it is necessary to have at least a Solidity compiler. There are several implementations:
Mix is an Open-Source IDE used for development on Ethereum. It includes editors for the different source codes, a Solidity compiler, and different tools to test contracts.
Blockchain disrupts data centers
The instantiation and deployment of contracts on the public blockchain costs Ether. The business model of blockchain is to, in quotes, “disrupt” data centres.
The idea is that everyone will be able to run their nodes and they will be paid to run the contracts and applications of others. So, every time a node executes a smart contract and validates a block, those nodes that are running applications are going to get paid directly. It’s like buying a VM from Amazon and going to pay Amazon to run your applications.
How you pay to run your applications is defined at the time of deployment of the smart contract. You must pay to deploy the smart contract. This money is going to be used to pay those who execute it
In addition, each time a transaction is sent, the people who will use your smart contract and ask it to do a particular task will pay a tiny bit _ this is called gas which corresponds to Ether for Ethereum _ to execute the transaction.
Blockchain is like a decentralized energy smart grid
The business model of blockchain is hyper distributed. We can make the analogy with the energy grid where each house will produce some energy. If we imagine that we can share energy between all the houses in a grid, then everyone is both a producer and a consumer. There is no need to centralize through EDF. By analogy, there is no need to centralize the hosting of applications. The idea is to have completely decentralized models.
How to test a DApp application during development?
During development, tests are generally done on local blockchains.
Of course, you are not going to test your contracts by deploying them on the public Ethereum blockchain because in this case, it’s like testing in production really and it will cost money.
The idea is to create your private chain on which you will also create virtual currencies, but they remain virtual currencies that have no counterpart in the real world and that will be used just for testing.
To avoid these problems, Test RPC is an implementation of the Ethereum blockchain “in memory”, useful for development and testing. It initializes an Ethereum blockchain with a genesis node with several accounts and it will give you the private keys of each of the accounts.
Truffle vs Embark: which development framework to choose for your DApps?
Truffle allows you to create a directory, you type truffle it in it, it will generate the skeleton of an Ethereum application and a smart contract+ frontend. When you do truffle deploy it will deploy it on the client that is running on your machine. If you have Test RPC, it will run it locally to see if it works and you will be able to run the unit tests.
These NPM packages offer classic tooling for developers:
- Solidity build automation
- Integration with unit testing tools
- Automate deployment
- Communicate with the blockchain
Why use JSON-RPC for your DApps?
The Blockchain is a “closed environment”: the only possible operations are those defined by EVM.
- How to visualize the data stored by a Smart Contract?
- How to access data stored outside the Blockchain?
- How to react to events occurring in the Blockchain?
We will have to develop DApps that will use the same JSON-RPC interface which is an RPC interface that uses JSON as a data structure to model the data that we send to the blockchain.
Different solutions exist. All of them are based on the JSON-RPC interface exposed by the Ethereum nodes. This RPC interface is exposed by all Ethereum nodes, whether they are public or test PC nodes.
The front end of the DApp is implemented in JS (single page in js) (Angular 2, …) and uses the web3.js library to communicate with an Ethereum node. The backend (Smart Contracts) is deployed on the Blockchain. The front end is then deployed publicly (Swarm) and the application is accessible to all Ethereum users (via Mist for example).
Get more information about DApps from our experienced team today.