Reader small image

You're reading from  Blockchain By Example

Product typeBook
Published inNov 2018
Reading LevelBeginner
PublisherPackt
ISBN-139781788475686
Edition1st Edition
Languages
Concepts
Right arrow
Authors (3):
Bellaj Badr
Bellaj Badr
author image
Bellaj Badr

Bellaj Badr is an experienced security and software engineer who loves blockchain with a passion. Currently, he is the CTO at Mchain, a blockchain start-up that develops blockchain solutions for companies. Alongside his role as CTO, he acts as technical consultant, offering strategic and technical consulting to many companies worldwide. Aside from this, he is involved in many blockchain projects involving the establishment of new blockchain business-oriented protocols. Badr is a frequent speaker at developer conferences and is father to two angels.
Read more about Bellaj Badr

Richard Horrocks
Richard Horrocks
author image
Richard Horrocks

Richard Horrocks is a freelance Ethereum and full-stack developer based in the UK, and holds a BA and MSc in natural sciences from the University of Cambridge. He worked for many years as a technical lead for Cisco Systems, where he worked on the operating systems of carrier-grade routing hardware, before leaving the world of IT to work as an English teacher. The advent of cryptocurrency piqued his interest sufficiently to lead him back to IT, and, since 2015, he has been working with Ethereum and other cryptocurrencies. His specialist interests are cryptoeconomics and incentive layers, with a particular focus on mechanism design and token engineering. When not in front of a computer, he enjoys yoga and falling off motorbikes.
Read more about Richard Horrocks

Xun (Brian) Wu
Xun (Brian) Wu
author image
Xun (Brian) Wu

Xun (Brian) Wu is a senior blockchain architect and consultant. With over 20 years of hands-on experience across various technologies, including Blockchain, big data, cloud, AI, systems, and infrastructure, Brian has worked on more than 50 projects in his career. He has authored nine books, which have been published by O'Reilly, Packt, and Apress, focusing on popular fields within the Blockchain industry. The titles of his books include: Learn Ethereum (First Edition), Learn Ethereum (Second Edition), Blockchain for Teens, Hands-On Smart Contract Development with Hyperledger Fabric V2, Hyperledger Cookbook, Blockchain Quick Start Guide, Security Tokens and Stablecoins Quick Start Guide, Blockchain by Example, and Seven NoSQL Databases in a Week.
Read more about Xun (Brian) Wu

View More author details
Right arrow

Preface

Blockchain is a disruptive technology that promises to disrupt many sectors of the global economy. This innovative technology aims to revolutionize those industries that rely on intermediation and trust by shifting the paradigm away from the currently dominant centralized architectures and toward decentralization.

The past couple of years have seen the exponential growth of blockchain, which has evolved into multiple forms and currently comprises many different technologies and tools, some mature, others relatively new, all of which makes understanding and mastering the key ideas and concepts a difficult task.

This is where this book enters the picture. There are many books out there aiming to capitalize on blockchain's current popularity, but, in our opinion, a vast majority of them concentrate on blockchain's theoretical or speculative aspects: in other words, what blockchain could be used for in future, without providing any concrete details on how these things can be achieved in practice. This book is different: it's more pragmatic. From the outset, this book details what can be done with blockchain technology now, and how to do it, by guiding the reader through a series of in-depth, hands-on implementations.

The book is organized into several main parts. It starts by providing an introduction and high-level overview of blockchain's concepts, before moving on to present different use cases and practical implementations based on the Ethereum, Bitcoin, and Hyperledger blockchains.

Who this book is for

This book is aimed at the blockchain novice, and aims to provide an easy way to learn how to conduct a blockchain-based project. It provides comprehensive coverage of the technical details associated with different blockchain solutions, and step-by-step guidance on implementing typical blockchain projects. By the end of the book, the reader will be able to build and maintain reliable and scalable distributed systems based on blockchain.

What this book covers

Chapter 1, Say Hello to Blockchain, serves as a general introduction, and explains the general concepts on which blockchain technology is based.

Chapter 2, Building a Bitcoin Payment System, introduces the specifics of Bitcoin by first building a customer-friendly payment system, before moving on to looking in more detail at the use of smart contracts on the Bitcoin blockchain.

Chapter 3, Building Your Own Cryptocurrency, builds on the general understanding of Bitcoin learned in the previous chapter to then create a new currency based on the Bitcoin code base.

Chapter 4, Peer-to-Peer Auction in Ethereum, introduces the basic features, concepts, and tools of Ethereum that are required to build a decentralized application. This chapter introduces the Solidity smart contract language that is used extensively in later chapters.

Chapter 5, Tontine Game with Truffle and Drizzle, builds on the previous Ethereum chapter to create a more complex decentralized application, leveraging more advanced features of Solidity, together with the Truffle development environment.

Chapter 6, Blockchain-Based Futures System, continues to build on the previous two Ethereum chapters, this time focusing on how smart contracts can interact with the outside world using oracles and third-party APIs.

Chapter 7, Blockchains in Business, introduces the idea of private enterprise blockchains and their use cases, before detailing how to implement a private network using an enterprise-focused fork of Ethereum called Quorum.

Chapter 8, Creating an ICO, continues the theme of using the Ethereum blockchain for business by describing, in detail, how to create and run an initial coin offering, also known as a token sale.

Chapter 9, Distributed Storage – IPFS and Swarm, builds on the previous Ethereum chapters to explore how to incorporate decentralized file storage in a decentralized application.

Chapter 10, Supply Chain on Hyperledger, introduces the third blockchain network of the book: Hyperledger. This chapter introduces the main concepts and basic features of Hyperledger, and how it differs from Bitcoin and Ethereum, before describing a practical implementation of how Hyperledger can be used to run a supply chain.

Chapter 11, Letter of Credit (LC) Hyperledger, builds on the basics from the previous chapter to implement a letter of credit issued between two banks and two transacting customers.

To get the most out of this book

The book assumes that you are comfortable using a command-line interface, though doesn't require any formal shell scripting skills. Basic language-agnostic programming knowledge is also assumed, and, in some cases, a familiarity with a particular language would be beneficial, though isn't a requirement.

As the book covers many languages and technologies, it is unlikely the reader will be familiar with all of them. As such, a willingness to learn is certainly recommended.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.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.packt.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/Blockchain-By-Example. 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: "You can, at any level, use console.log() to print the received values in the console."

A block of code is set as follows:

var bitcoin = require('bitcoinjs-lib');
var rp = require('request-promise');

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

sudo add-apt-repository ppa:bitcoin/bitcoin 
sudo apt-get update

Bold: Indicates a new term, an important word, or words that you see on screen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "The customer can check the transaction details before proceeding with the payment by pressing the Transaction details button."

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 customercare@packtpub.com.

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 www.packt.com/submit-errata, 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 copyright@packt.com 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 authors.packtpub.com.

Reviews

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 packt.com.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Blockchain By Example
Published in: Nov 2018Publisher: PacktISBN-13: 9781788475686
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (3)

author image
Bellaj Badr

Bellaj Badr is an experienced security and software engineer who loves blockchain with a passion. Currently, he is the CTO at Mchain, a blockchain start-up that develops blockchain solutions for companies. Alongside his role as CTO, he acts as technical consultant, offering strategic and technical consulting to many companies worldwide. Aside from this, he is involved in many blockchain projects involving the establishment of new blockchain business-oriented protocols. Badr is a frequent speaker at developer conferences and is father to two angels.
Read more about Bellaj Badr

author image
Richard Horrocks

Richard Horrocks is a freelance Ethereum and full-stack developer based in the UK, and holds a BA and MSc in natural sciences from the University of Cambridge. He worked for many years as a technical lead for Cisco Systems, where he worked on the operating systems of carrier-grade routing hardware, before leaving the world of IT to work as an English teacher. The advent of cryptocurrency piqued his interest sufficiently to lead him back to IT, and, since 2015, he has been working with Ethereum and other cryptocurrencies. His specialist interests are cryptoeconomics and incentive layers, with a particular focus on mechanism design and token engineering. When not in front of a computer, he enjoys yoga and falling off motorbikes.
Read more about Richard Horrocks

author image
Xun (Brian) Wu

Xun (Brian) Wu is a senior blockchain architect and consultant. With over 20 years of hands-on experience across various technologies, including Blockchain, big data, cloud, AI, systems, and infrastructure, Brian has worked on more than 50 projects in his career. He has authored nine books, which have been published by O'Reilly, Packt, and Apress, focusing on popular fields within the Blockchain industry. The titles of his books include: Learn Ethereum (First Edition), Learn Ethereum (Second Edition), Blockchain for Teens, Hands-On Smart Contract Development with Hyperledger Fabric V2, Hyperledger Cookbook, Blockchain Quick Start Guide, Security Tokens and Stablecoins Quick Start Guide, Blockchain by Example, and Seven NoSQL Databases in a Week.
Read more about Xun (Brian) Wu