Book Image

Blockchain Quick Start Guide

By : Xun (Brian) Wu, Weimin Sun
Book Image

Blockchain Quick Start Guide

By: Xun (Brian) Wu, Weimin Sun

Overview of this book

Blockchain is a technology that powers the development of decentralized applications.This technology allows the construction of a network with no single control that enables participants to make contributions to and receive benefits from the network directly. This book will give you a thorough overview of blockchain and explain how a blockchain works.You will begin by going through various blockchain consensus mechanisms and cryptographic hash functions. You will then learn the fundamentals of programming in Solidity – the defacto language for developing decentralize, applications in Ethereum. After that, you will set up an Ethereum development environment and develop, package, build, and test campaign-decentralized applications.The book also shows you how to set up Hyperledger composer tools, analyze business scenarios, design business models, and write a chain code. Finally, you will get a glimpse of how blockchain is actually used in different real-world domains. By the end of this guide, you will be comfortable working with basic blockchain frameworks, and develop secure, decentralized applications in a hassle-free manner.
Table of Contents (14 chapters)
Title Page
Copyright and Credits
About Packt


Just as we were at the dawn of the internet age in the nineties, we are at the dawn of the blockchain age now. This new technology will disrupt existing business models and give birth to new ones. It will inspire the emergence of community economies built on blockchain networks, where every participant makes contributions to and receives benefits from the community. There will no longer be a single entity controlling and receiving dividends from the economy.

Thanks to its immutability, transparency, and the consensus mechanism for avoiding double-spending, along with other clever designs such as blocks chained with the hashes of the previous blocks, the technology allows untrusting parties to trade with each other directly. As a result, most of the intermediary services currently provided by existing institutions will no longer be needed. As a consequence, blockchain technology is receiving attention the world over.

There are many articles and books on blockchain. However, there are no good books serving beginners who are looking for a quick way to gain a good understanding of the technology as a whole and learn what's needed to be able to develop a complete blockchain application. This quick guide fills in this gap. The book covers coding details on how to develop blockchain applications on Ethereum and Hyperledger Fabric, the two most popular platforms for public and enterprise blockchain, respectively.

Who this book is for

This book benefits readers who are new to the blockchain technology and want to learn about its basics and jump start their development of smart contracts and Decentralized Applications (DApps). Business readers can especially gain from the first two chapters along with the last chapter, which cover what business issues need to be addressed and what possible use cases there are for blockchain. IT readers should read all the chapters and learn how to develop smart contracts and DApps via the many working examples presented in this book.


What this book covers

Chapter 1, Introduction to Blockchain Technology, gives an overview of blockchain and its key concepts, such as cryptography and hash algorithms, the distributed ledger, transactions, blocks, proof of work, mining, and consensus. We cover Bitcoin, the mother of blockchain technology, in detail. We briefly introduce Ethereum by pointing out some limitations of Bitcoin and how they are addressed by Ethereum. While Bitcoin and Ethereum are examples of public blockchains, IBM's Hyperledger is used as an example of enterprise blockchains. Toward the end of this chapter, we look at the evolution of blockchain, through 1.0, 2.0, 3.0, and beyond, and we examine their use cases.

Chapter 2, Ethereum Fundamentals, covers the basic concepts of Ethereum, such as smart contracts, ether, consensus algorithms, EVM, gas, and accounts. We will discuss Ethereum performance and review ideas on how to improve the overall performance via proof of work, casper, plasma, and sharding.

Chapter 3, Overview of Solidity Programming, discusses what solidity is, as well as the tools for the solidity development environment. We then discuss smart contracts and their common patterns. We cover the important topic of smart contract security. Finally, we show how to write a smart contract with a use case of crowdfunding.

Chapter 4, Building an Ethereum Blockchain Application, looks at what a DApp is. We give a quick overview of web3.js. We explain how to set up an Ethereum development environment, as well as how to develop and test a DApp.

Chapter 5, Exploring an Enterprise Blockchain Application Using Hyperledger Fabric, gets into the key concepts of Hyperledger Fabric, along with the core components. We explain how to create a Hyperledger Fabric environment, how to write a chaincode, and how to set up Hyperledger Fabric configuration.

Chapter 6, Implementing a Business Network Using Hyperledger Composer, provides an overview of Hyperledger Composer and talks about how to set up a Hyperledger Composer environment. We discuss business scenarios, the business network archive, and how to implement a business transaction function.


Chapter 7, Blockchain Use Cases, first talks about popular blockchain use cases across industries, including the financial sector, civil services, supply chains, the Internet of Things (IoT), and healthcare, at a high level. We will then proceed to a discussion of the proper use cases for DApps, before then developing a successful DApp. Finally, we take the health data-sharing use case and comment at a high level on building an DApp for it.

To get the most out of this book

We've focused on organizing the book to fit business and IT beginners in blockchain technology. The chapters are arranged to ensure that they can be followed easily and flow naturally.

Business users can skip the chapters with detailed descriptions on how to develop blockchain applications and, instead, focus on the chapters with general descriptions of the technology and use cases.

Veteran IT professionals on blockchain can skip the general description chapters and focus on chapters either on Ethereum or Hyperledger, from which they will gain insights on how to build blockchain applications.

It is recommended that IT users download the code and make modifications for adopting to their own use cases or exercises.

Download the example code files

You can download the example code files for this book from your account at If you purchased this book elsewhere, you can visit and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.


Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at Check them out!


Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "One important interface is ChaincodeStubInterface, which provides functions that allow you to query, update, and delete assets in the ledger."

A block of code is set as follows:

contract SimpleStorage {
    uint storedData; // State variable

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

pragma solidity ^0.4.15;
import 'zeppelin/contracts/math/SafeMath.sol';
contract ExampleCoin is ERC20 {
  //SafeMath symbol is from imported file SafeMath.sol'
  using SafeMath for uint256;


Any command-line input or output is written as follows:

mkdir ~/insurance-claim && cd ~/insurance-claim

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "When the preceding request is validated by mining nodes, the HelloWorld smart contract is invoked."


Warnings or important notes appear like this.


Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit




Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit