Build Your First Blockchain Application in 5 Quick Steps

Build Your First Blockchain Application in 5 Quick Steps

To say there is hype around blockchain is an understatement. But in order for this revolution to keep advancing, we need more engineers! Recently, it was&nbsp;<a href="" target="_blank">announced</a>&nbsp;that there are 14 job openings for every one blockchain engineer.

To say there is hype around blockchain is an understatement. But in order for this revolution to keep advancing, we need more engineers! Recently, it was announced that there are 14 job openings for every one blockchain engineer.

It’s clear that there’s a talent scarcity and the goal of this tutorial is to provide a blockchain foundation where you can quickly build your first full-stack decentralized application (DApp).

We will be building a DApp that works as a voting system and the code can be found here. This tutorial will go over creating, compiling, and deploying the contract on a local blockchain network. You will then have the ability to interact with the contract via a nodejs cosole or a webpage GUI.

Keep in mind that this can be completed with limited technical knowledge but it was designed for those that have a little coding experience. As we go through the steps, there will be a brief background on the process meant to serve as a high level overview. If any particular areas catch your interest, don’t hesitate to Google around for more information.

This is a lightweight approach that allows you to hit the ground running with a full stack project. This tutorial features no frameworks, limited dependencies, and no BS.

Lets jump right in…

Step 1: Clone repository and install dependencies

# Clone the source repository
git clone

Check that npm and node are installed

The tutorial was created with the below versions

created with the below versions) $ npm -v v7.10.1 $ node -v 4.2.0

Ganache is a blockchain simulator that runs in memory locally. We will be using this as the test Ethereum blockchain for our app:

$ npm install ganache-cli [email protected]

Solidity code must be compiled. We will use “solc” to compile our solidity code:

$ npm install solc

Step 2: Run the Ganache CLI

$ node_modules/.bin/ganache-cli

Expected output:

Step 3: Compile the Contract

We will compile the contract from within the nodejs console:

/voting-blockchain-app $ node
> Web3 = require('web3')
> web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

We can ensure that the web3 object is initialized and can communicate with the blockchain by using the ‘accounts’ method on the object:

To compile the contract, load the solidity code from voting.sol into a string variable then compile (will run in a nodejs console as well):

> code = fs.readFileSync('voting.sol').toString()
> solc = require('solc')
> compiledCode = solc.compile(code)

Step 4: Deploy the Contract

Create a contract object and deploy the contract:

> abiDefinition = JSON.parse(compiledCode.contracts[':voting'].interface)
> VotingContract = web3.eth.contract(abiDefinition)
> byteCode = compiledCode.contracts[':voting'].bytecode
> deployedContract =['Bill','Tom','Janice'],{data: byteCode, from: web3.eth.accounts[0], gas: 4700000})
> deployedContract.address
> contractInstance =

FYI — Interacting with the blockchain costs money. We are specifying how much we are willing to pay for our code to be included in the blockchain through the gas amount above. This amount will be given to the miners so that our code can be included in the blockchain.

Step 5: Interact with the contract

First, we are going to interact with the contract through a node console:

Output: { [String: '0'] s: 1, e: 0, c: [ 0 ] }
> contractInstance.voteForCandidate('Bill', {from: web3.eth.accounts[0]})
Output: '0xdedc7ae544c3dde74ab5a0b07422c5a51b5240603d31074f5b75c0ebc786bf53'
> contractInstance.voteForCandidate('Tom', {from: web3.eth.accounts[0]})
> contractInstance.voteForCandidate('Tom', {from: web3.eth.accounts[0]})

We can also interact with the contract through a lightweight, web GUI.

In order to use the GUI, you will need to update the contract instance address in /voting-blockchain-app/index.js for your contract

# In your nodejs console, execute contractInstance.address to 

get the address at which the contract is deployed and change

the line below to use your deployed address

contractInstance ='0xe46c0742867695226bdacc9b821d7f26dbdd294e');

Open ~/voting-blockchain-app/index.html in your browser. You should see the below and be able to interact by entering a candidate’s name (Bill, Tom, Janice) and clicking ‘Vote’:

The goal of this tutorial was to provide a quick, concise introduction to building your first blockchain application. By understanding the full stack flow, it is easy to tweak this toy application or build something completely new.

A good next step is to dive into the Ethereum documentation available here. There you can learn to build anything from more advanced DApps to crowdsales to building your own cryptocurrency!

bitcoin blockchain cryptocurrency

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

What Is The Difference Between Blockchain And Bitcoin?

Get hands on experinece on block chain live industry experts with real world example at Block chain online Training. Enroll for free demo

The Bitcoin Blockchain Explained

Learn how Bitcoin works and how the “blockchain” tech behind it can be used to produce business value beyond digital currencies.

Blockchain along with Data Science: A powerful combination

Blockchain has became the new buzzword in recent times. Though it was earlier known for the usage of bitcoin and other cryptocurrencies, now this technology has attracted the interests of several governments in the world to be integrated with...

Revolutionary Application of Blockchain Technology

Our Blockchain Online Training will provide you to learn about Blockchain technology aspects with realty. Our Blockchain Course also includes live sessions, live Projects

Securing media content using Blockchain Technology

Venture-backed blockchain and cryptocurrency startups are mushrooming across Silicon Valley. To get most out of blockchain, media & broadcasting industry is hoping to get some of its longstanding problem resolved through the technology.