Book Image

Mastering Blockchain - Second Edition

By : Imran Bashir
Book Image

Mastering Blockchain - Second Edition

By: Imran Bashir

Overview of this book

Publisher's Note: This edition from 2018 is outdated and does not cover the latest insights on consensus algorithms, Ethereum 2.0, tokenization, and enterprise blockchains. A new and updated edition of this book that includes all the newest developments and improvements in Blockchain including the above topics is now available. A blockchain is a distributed ledger that is replicated across multiple nodes and enables immutable, transparent and cryptographically secure record-keeping of transactions. The blockchain technology is the backbone of cryptocurrencies, and it has applications in finance, government, media and almost all other industries. Mastering Blockchain, Second Edition has been thoroughly updated and revised to provide a detailed description of this leading technology and its implementation in the real world. This book begins with the technical foundations of blockchain technology, teaching you the fundamentals of distributed systems, cryptography and how it keeps data secure. You will learn about the mechanisms behind cryptocurrencies and how to develop applications using Ethereum, a decentralized virtual machine. You will also explore different other blockchain solutions and get an introduction to business blockchain frameworks under Hyperledger, a collaborative effort for the advancement of blockchain technologies hosted by the Linux Foundation. You will also be shown how to implement blockchain solutions beyond currencies, Internet of Things with blockchain, blockchain scalability, and the future scope of this fascinating and powerful technology.
Table of Contents (21 chapters)
14
Introducing Web3
17
Blockchain – Outside of Currencies
18
Scalability and Other Challenges

To get the most out of this book

  • All examples in this book have been developed on Ubuntu 16.04.1 LTS (Xenial) and macOS version 10.13.2. As such, it is recommended to use Ubuntu or any other Unix like system. However, any appropriate operating system, either Windows or Linux, can be used, but examples, especially those related to installation, may need to be changed accordingly.
  • Examples related to cryptography have been developed using the OpenSSL 1.0.2g 1 Mar 2016 command-line tool.
  • Ethereum Solidity examples have been developed using Remix IDE, available online at https://remix.ethereum.org
  • Ethereum Byzantine release is used to develop Ethereum-related examples. At the time of writing, this is the latest version available and can be downloaded from https://www.ethereum.org/.
  • Examples related to IoT have been developed using a Raspberry Pi kit by Vilros, but any aapropriate latest model or kit can be used. Specifically, Raspberry Pi 3 Model B V 1.2 has been used to build the hardware example of IoT. Node.js V8.9.3 and npm V5.5.1 have been used to download related packages and run Node js server for IoT examples.
  • The Truffle framework has been used in some examples of smart contract deployment, and is available at http://truffleframework.com/. Any latest version available via npm should be appropriate.

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support 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 www.packtpub.com.
  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 https://github.com/PacktPublishing/Mastering-Blockchain-Second-Edition. 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 https://github.com/PacktPublishing/. Check them out!

Download the color images

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: "After executing the command, a file named privatekey.pem is produced, which contains the generated private key as follows."

A block of code is set as follows:

pragma solidity ^0.4.0; 
contract TestStruct { 
  struct Trade 
  { 
    uint tradeid; 
    uint quantity; 
    uint price;  
    string trader; 
  } 
 
  //This struct can be initialized and used as below 
 
  Trade tStruct = Trade({tradeid:123, quantity:1, price:1, trader:"equinox"}); 
 
} 

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.0; 
contract TestStruct { 
  struct Trade 
  { 
    uint tradeid; 
    uint quantity; 
    uint price;  
    string trader; 
  } 
 
  //This struct can be initialized and used as below 
 
  Trade tStruct = Trade({tradeid:123, quantity:1, price:1, trader:"equinox"}); 
 
} 

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

$ sudo apt-get install solc 

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: "Enter the password and click on SEND TRANSACTION to deploy the contract."

Warnings or important notes appear like this.
Tips and tricks appear like this.