O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Blockchain By Example

Book Description

Dive into working mechanics of the decentralized blockchain applications to build your own scalable dapps

About This Book
  • Guide to help you learn Blockchain ecosystem and their terminologies
  • Implement smart contracts, wallet, consensus protocols, and other principles
  • Design and develop decentralized applications using Bitcoin, Ethereum, and Hyperledger
Who This Book Is For

If you are keen on learning how to build your own blockchain decentralized applications from scratch, then this book is what you need. Implement key building blocks of a blockchain ecosystem with this handy guide. It explains all the basic concepts required to develop intermediate projects

What You Will Learn
  • Grasp the decentralized technology fundamentals to master blockchain principles.
  • Build blockchain projects on Bitcoin, Ethereum, and Hyperledger.
  • Create your own currency and a payment application using Bitcoin
  • Implement Web3.js apps and supply chain system using Hyperledger.
  • Write smart contracts, run your ICO and build tontine decentralized app using Ethereum
  • Explore Blockchain to learn how to implement distributed file management.
  • Integrate blockchain into your existing systems in your organization
In Detail

The blockchain is a revolution promising a new world without middlemen. Technically, it is an immutable and tamper-proof distributed ledger of all transactions across a peer-to-peer network. With this book, you will set a foundation to get into the grips of blockchain ecosystem to build real-world projects.

Throughout the book, we will walk you through a detailed step-by-step process using solidity to build three blockchain projects with different complexity levels and hurdles. This book will provide you with all the relevant concepts related to cryptocurrencies, smart contracts, and blockchain in order to build your own decentralized applications. Each project will teach you just enough about blockchain to be productive right away. We will cover the different set of projects such as Bitcoin Payment System, Supply Chain on Hyperledger, and Tontine Bank Dapp using Ethereum. We will cover major challenges that are associated with Blockchain ecosystems such as scalability, integration, distributed file management and more.

By the end of this book, you will not only be able to tackle the common issues in the blockchain ecosystem but also design and build reliable, scalable distributed systems.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Preface
  2. Chapter 1 : Say Hello to blockchain
    1. Introduction
    2. Emergence of blockchain and cryptocurrency
      1. From virtual to crypto currency
      2. What is a Blockchain?
        1. Blocks
        2. Transactions
        3. Smart contracts
    3. Say "hello" to the Blockchain
      1. Getting started
        1. Run a bitcoin client for the first time 
        2.  Synchronizing the blockchain
          1. Running Bitcoin core in pruned mode
          2. Run Electrum client:
      2. Method 1: Building raw transaction using bitcoin client
        1. Funding our addresses
        2. Unspent Transaction Output
        3. Creating the transaction
          1. Transaction structure
        4. Signing the transaction 
        5. Sending the transaction
        6. Retrieve your message online from the blockchain
        7. Retrieve your message from the local blockchain
      3. Method 2 : Build a raw bitcoin transactions in JavaScript .
        1. Preparation
        2. Let's code
    4. Types of blockchains
      1. Classification of blockchains
    5. Summary
  3. Chapter 2 : Building a Bitcoin payment system
    1. Introduction
    2. What is Bitcoin?
      1. Why choose Bitcoin as platform?
    3. Getting started with Bitcoin
      1.  Setting up regtest environment
        1. First commands
      2. Transactions in Bitcoin
        1. Mining 
        2. Bitcoin Scripting
          1. Building p2pkh script using JavaScript
          2. Building a custom script
    4. Building a payment gateway
      1. Project description
        1. Bitcoin payment protocol overview
      2. Prerequisites
      3. Project setup
        1. Certificate management
      4. Merchant side
        1. Building payment request URI
        2. Routing
          1. Checkout view
          2. Proceeding with payment
          3. Requesting payment details
          4. Receiving and acknowledging payment
          5. Invoicing
      5. Client side
      6. Preview your application
    5. Payment protocol using BITCOINJ
      1. Prerequisites
        1. BitcoinJ installation
      2. BitcoinJ client
        1. Bitcoin wallet configuration
        2. Requesting payment
        3. Sending a payment
        4. Testing code
    6. Bitcoin smart contracts
      1. What's Rootstock
        1. Rootsock setup
        2. Interactions with RSK
        3. Accounts settings
      2. Writing your first Bitcoin smart contract
        1. Deploying the contract
        2. Interacting  with the contract
    7. Summary
  4. Chapter 3 : Building your own cryptocurrency
    1. Introduction
    2. Compiling Bitcoin from source
      1. Preparing your build system
        1. Installing dependencies
          1. Bitcoin-qt: Qt5 GUI for Bitcoin
        2. Cloning the Bitcoin source code
      2. Building Bitcoin Core
        1. Checking your build worked
    3. New cryptocurrency: ReaderCoin
      1. Cloning Bitcoin
      2. Readercoin rebranding
      3. Changing the ports
      4. Changing pchMessageStart
      5. Genesis block
        1. New pszTimestamp
        2. New nonce, epoch time, and nbits
        3. New genesis hash
        4. Editing the Merkle root
      6. Removing the seed nodes
      7. Checkpoints
      8. ChainTxData
      9. Rewarding
      10. Halving
      11. Total supply
      12. POW parameters: target
        1. New block time
          1. Difficulty adjustment time interval 
          2. Difficulty adjustement rate
      13. Time maturity
      14. Block size
      15. BIPs: Bitcoin Improvement Proposals
      16. Compiling and testing
      17. Design and graphics (Qt wallet)
      18. Redesign of the Bitcoin-Qt wallet
        1. Graphical interface addition
      19. Building Readercoin network
      20. Readercoin mining
      21. Sending transactions
      22. Building a transaction and block explorer
        1. Iquidus setup requirements
        2. Creating Iquidus' database
        3. Installing Iquidus
          1. Iquidus Configuration
        4. Syncing databases with the blockchain
        5. Wallet preparation
        6. Starting the explorer
      23. Building an exchange market
    4. Summary
  5. Chapter 4 : Peer to peer auction in Ethereum
  6. Chapter 5 : Tontine game with Truffle and Drizzle
  7. Chapter 6 : Blockchain-based Futures system
  8. Chapter 7: Blockchains in business
  9. Chapter 8: Creating an ICO
  10. Chapter 9: Distributed Storage: IPFS and Swarm
  11. Chapter 10 Supply chain on Hyperledger
  12. Chapter 11 Letter of credit (LC) Hyperledger