Three essential tools to develop a DApp on the Ethereum Blockchain
6 November 2017Blockchain technologies such as Bitcoin or Ethereum are used to set up currencies, called cryptocurrencies, but this is not the only purpose. Thanks to the decentralized protocol you can simulate any applications. Today, with web3, the Ethereum JavaScript API, it is possible to develop decentralized applications: DApps.
At first, developing an application on the Blockchain might seem complicated. How can I implement an application that does not run on a server but within a decentralized system? Where to start? What are the tools?
At SingularGarden, we have developed an Ethereum application called “OyéOyé” [oh-yeah-oh-yeah]. It’s a simple guestbook that allows us to demonstrate the following concept:
- running a DApp in the browser
- money transfer
- data storage
Here are the tools we used to make this application.
TestRPC: simulate the Ethereum Blockchain
Just a reminder, to deploy or execute a smart contract on the Blockchain you have to pay GAS cost. Smart contracts are immutable, they need to be well tested before being deployed.
TestRPC is one of the Ethereum clients to simulate an Ethereum network locally. You can run and test your smart contracts on it before deploying them on the Main Network and configure it as you want! For example, get yourself an infinite number of Ether or modify GAS market price.
Install it with npm
:
npm install -g ethereumjs-testrpc
To start a local Ethereum network:
testrpc
Congrats! You just created your first Ethereum local network!
It is running on localhost:8545
.
Truffle: toolsuite for Ethereum smart contracts
Truffle is a framework to develop Solidity-based smart contracts in an easier way. Solidity is the most used language to develop smart contracts. It has a similar syntax as JavaScript and is compiled to the low level language of the Ethereum Virtual Machine (EVM).
Truffle has built-in smart contract compilation, testing and deployment. Also it gives you a contract abstraction from JavaScript which simplify the communication between smart contracts and the front-end. Finally, Truffle is compatible out of the box with TestRPC and web3.
Truffle is available on npm
:
npm install -g truffle
To create a new project:
mkdir myFirstDApp && cd myFirstDApp && truffle init
To this day, November 2017, you get the following project structure:
contracts/
where smart contracts should bemigrations/
where deployment files should betest/
where test files for testing your application and contracts should betruffle.js
your Truffle configuration file
truffle init
gives you two smart contract examples: MetaCoin
and ConvertLib
.
MetaMask: Ethereum client for the web
Blockchain systems such as Ethereum are giant networks of nodes. To interact with the network you communicate through one of these nodes. MetaMask is a light node that runs in your browser. It exposes web3 API which are necessary to run a DApp. With this, you will be able to use the Ethereum network directly from your browser. No unsafe gateway: you own the node.
MetaMask is a Google Chrome extension only, for the moment. You can connect to different Ethereum networks like the Main Network, or test networks like Ropsten called testnets or also to local network like TestRPC.
Install MetaMask through the Chrome Web Store.
From MetaMask icon in Chrome menu, you will be able to create a new wallet. Make sure to save the 12 seeds words somewhere safe. These are the only way to recover your password if you lose it. At the end, MetaMask should look like this:
Metamask connects to the Main Network by default. If you click on it, you will be able to change network and choose for example localhost:8545
to connect MetaMask to your local Ethereum network ran by TestRPC.
Finally
We saw the three essentials tools that you need to develop a DApp on the Ethereum Blockchain. With these, you can start your own DApp, test it and deploy it to the Main Network. It’s quite fast and simple once you are familiar with the toolsuite!
In the next article, we will see how to develop a complete DApp with a front-end and smart contracts. Register to our newsletter to keep in touch!
Photo par [Barn Images] (https://unsplash.com/photos/t5YUoHW6zRo).
Laurent Senta
I wrote software for large distributed systems, web applications, and even robots.
These days I focus on making developers, creators, and humans more productive through IPDX.co.