Thanks for signing up.
We'll see you soon 👋
We'll see you soon 👋
There’s currently a mass adoption of cryptocurrency and the blockchain industry is quickly gaining traction. As a result of this, companies are looking to hire individuals with skills capable enough to build the next billion-dollar blockchain company.
This article is an introduction to building decentralized applications (dapps) with the currently trending technologies in space. This article assumes that readers intend to learn the basics of building dapps, and as a result does not leave any stone uncovered, as it addresses the core basics of building a dapp.
At the end of the article, readers would be enlightened on what a dapp is, what Web3.js, Solidity, and Truffle are all about, and how to build a dapp with these technologies.
Decentralized apps (dapps) are digital applications or programs that exist with their backend code running on the blockchain or peer-to-peer (P2P) network, meaning that data in the context of a dapp is decentralized and free from control by a single authority, in contrast to a standard web or mobile app where backend code is running on centralized servers and information is owned and controlled by a single authority.
Since blockchain - what some refer to as web3, is the driving force behind dapps, the backend consists of a collection of computers, and these thousands of computers that make up dapp network are called nodes. With this decentralized model, it is practically impossible for its database to be tampered with because if one node is altered, all other nodes can easily point out the node that has incorrect information. This helps to establish transparency. This decentralized system also means that data is continuously managed collectively and is consumed and shared simultaneously by all users. The higher the number of participants, the stronger the network becomes.
The rules that guide activities within dapps are formalized by the majority consensus of all network participants, who also receive native network tokens for providing computing power required to keep the network running. Consider a scenario where the account of the president of the United States of America would immediately be deleted on twitter if all tweeps agree that such should be done.
The following are the benefits of using dapps:
Dapps are still largely experimental and face some challenges too, these include:
Web3.js, Solidity, and Truffle are the most common terms associate with Blockchain app development. Why don't we kickstart our journey to becoming aware of these tools used for building apps?
It is a build-up of 5 modules that have specific functions, and the main class; called Web3, which holds the bulk functionality of the library. The various modules are: web3-eth: To interact with the Ethereum blockchain. web3-shh: To interact with Whisper protocol. web3-bzz: To interact with Swarm - decentralized storage. web3-net: To interact with Ethereum nodes. web3-utils: To provide utility functions in Ethereum dapps.
Solidity is much more than a programming language. It is setting the standard for the future of blockchain technology. However, like Ethereum, Solidity is undergoing visionary growth, and the language still deals with frequent updates and modifications.
Truffle is a framework made for building, testing, and deploying dapps on the Ethereum network. It is widely noted as the most popular development tool for blockchain developers, whether they are building on Ethereum, Hyperledger, Quorum, or any other supported platform.
Truffle aims to make the life of a developer easy by abstracting the many complexities of Web3 and Ethereum during blockchain app development, which makes writing dapp codes easier and more predictable and allows for rapid lightweight testing and iteration.
Along with Ganache, a personal blockchain for Ethereum development, and Drizzle, a custom frontend dapp development kit, the Truffle suite of tools is sure to get developers from idea to dapp as comfortably as possible.
As a blockchain developer, it’s up to you to determine which library might be best for you - depending on your needs. Before looking at the range of possible solutions, take some time to document your goals.
Although the Truffle framework provides a blockchain developer with the ability to interact with blockchain data, the process to access and evaluate the data isn’t so easy or elegant. In this section we will find out the various great options that are available to allow blockchain developers to easily develop clients that interact with blockchain data, then we’ll have a look at why web3.js is an elegant and easy-to-use library for accessing blockchain data.
Various Ethereum blockchain access libraries include:
Web3.py: If you’re a Python developer, this would be your go-to library for interacting with the Ethereum blockchain. It’s a python implementation of web3.js and useful when building analytics-related blockchain applications.
Truffle-contract: Used internally by the Truffle framework to interact with blockchain data. It provides great integration if you want to access and evaluate smart contracts with the Truffle framework.
**Keep in mind that there are more other alternatives for accessing blockchain data in other languages like Java, as well.
Why choose web3.js? In a few words:
Now, it’s time for us to explore these points in more detail. Believe me, you’ll want to read until the end to find out why it’ll be a great choice to use web3.js for your next blockchain project.
Among the client libraries for blockchain development, web3.js is the most popular. A lot of decentralized applications have been developed using the library. With over 11,700 stars on GitHub and used by over 51,000 repositories at the time of writing this article, web3.js is a very popular project on GitHub. This also means that there are a lot of people questioning, supporting, and contributing to it. As such, this results in more reliable software.
Ethereum Name Service (ENS) has similar goals to DNS, the Internet’s Domain Name Service. Its importance is in mapping human-readable names like ‘tina.eth’ to machine-readable identifiers such as Ethereum addresses, other cryptocurrency addresses, content hashes, and metadata. With web3.js, it’s very easy to integrate ENS into dapps.
Web3.js has an extensive API reference that is very useful. Whether you are working on a new cutting edge decentralized application or you’re simply ramping up on a new blockchain product, the web3.js documentation has all the information you need to get you up and running towards making your project a smashing success.
As a developer, it’s ideal to use libraries that are updated frequently, this enhances productivity, improves performance, and removes outdated functions from our software.
The GNU Lesser General Public License (LGPL) is an appealing option for developers looking to balance contributing to the OSS (Open Source Software) community with a desire to have their code incorporated into proprietary software. It’s also attractive, as it protects potential users from expensive lawsuits. In addition, the license is backed by the GNU Project, a well-known and respected organization in the open-source software domain.
Picking a blockchain user-client library for yourself or your team is not a decision to take lightly. Knowing Web3.js is a library that is the industry standard in blockchain development, constantly growing upwards, with a very strong and large community, has the most helpful resources, and has major blockchain projects making use of it, it’s clear to see why Web3.js is an incredible option and a go-to library for interacting with the Ethereum blockchain.
In this section, we will have a look at the project that we will eventually build in part two of this series. It will be a project where I show you step-by-step how to use web3.js to talk to the Ethereum blockchain as we build a dapp using web3.js, solidity, and truffle.
The project we are going to build is a voting application, a very simple one that allows us to hold an election between two candidates. Solidity is the language we will use. We will also write tests against our app and deploy it to the Ethereum blockchain. We will develop a client-side application that interacts with our smart contract on the blockchain, It will have a form that will allow our users to cast votes, and a table for election results that lists each candidate’s id, name, and vote count.
Just before we get going in part two, we can already install the dependencies that we will need to build our dapp. They are:
npm install -g truffle
Now that we have our dependencies installed, we can easily get up and running with building our dapp in part two.
In this first part of the series, we have covered, the basics of building a dapp; in the first section. In the second section, we learned what dapps are, along with the benefits and drawbacks that are associated with dapps. We also learned about the several important pieces (let’s call them components) that provide the core of functionalities when building a viable decentralized application, or any kind of application that interacts with blockchain data. The components included an effective way to write code that writes to, and reads from a blockchain node (Web3.js), a test blockchain for development (Ganache), and a testing, building, and deployment framework (Truffle); in section three. Then, we came across various reasons why web3.js is a great option for blockchain developers to use as their user-client component. Finally, we had an overview of a simple decentralized application that we will be building in the second part of this series.
As I mentioned in the beginning, there’s currently a mass adoption of cryptocurrency and the blockchain industry is quickly gaining traction. As such, this is a great time to harness the skills and learn the right technologies needed to make you stand out as a blockchain developer.
Engineers who find a new job through Blockchain Works average a 15% increase in salary.Start with GitHubStart with TwitterStart with Stack OverflowStart with Email