Building Blockchain Projects

Book description

Develop real-time practical DApps using Ethereum and JavaScript

About This Book

  • Create powerful, end-to-end applications for Blockchain using Ethereum
  • Write your first program using the Solidity programming language
  • Change the way you think and design your applications by using the all new database-Blockchain

Who This Book Is For

This book is for JavaScript developers who now want to create tamper-proof data (and transaction) applications using Blockchain and Ethereum. Those who are interested in cryptocurrencies and the logic and database empowering it will find this book extremely useful.

What You Will Learn

  • Walk through the basics of the Blockchain technology
  • Implement Blockchain's technology and its features, and see what can be achieved using them
  • Build DApps using Solidity and Web3.js
  • Understand the geth command and cryptography
  • Create Ethereum wallets
  • Explore consortium blockchain

In Detail

Blockchain is a decentralized ledger that maintains a continuously growing list of data records that are secured from tampering and revision. Every user is allowed to connect to the network, send new transactions to it, verify transactions, and create new blocks, making it permission-less.

This book will teach you what Blockchain is, how it maintains data integrity, and how to create real-world Blockchain projects using Ethereum. With interesting real-world projects, you will learn how to write smart contracts which run exactly as programmed without any chance of fraud, censorship, or third-party interference, and build end-to-end applications for Blockchain.

You will learn about concepts such as cryptography in cryptocurrencies, ether security, mining , smart contracts, solidity, and more. You will also learn about web sockets, various API services for Ethereum, and much more.

The blockchain is the main technical innovation of bitcoin, where it serves as the public ledger for bitcoin transactions.

Style and approach

This is a project-based guide that not only gets you up and running with Blockchain, but also lets you create intuitive real-world applications that will make you an independent Blockchain developer.

Publisher resources

Download Example Code

Table of contents

  1. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the example code
      2. Downloading the color images of this book
      3. Errata
      4. Piracy
      5. Questions
  2. Understanding Decentralized Applications
    1. What is a DApp?
      1. Advantages of decentralized applications
      2. Disadvantages of decentralized applications
    2. Decentralized autonomous organization
    3. User identity in DApps
    4. User accounts in DApps
    5. Accessing the centralized apps
    6. Internal currency in DApps
      1. Disadvantages of internal currency in DApps
    7. What are permissioned DApps?
    8. Popular DApps
      1. Bitcoin
        1. What is a ledger?
        2. What is blockchain?
        3. Is Bitcoin legal?
        4. Why would someone use Bitcoin?
      2. Ethereum
      3. The Hyperledger project
      4. IPFS
        1. How does it work?
          1. Filecoin
      5. Namecoin
        1. .bit domains
      6. Dash
        1. Decentralized governance and budgeting
        2. Decentralized service
      7. BigChainDB
      8. OpenBazaar
      9. Ripple
    9. Summary
  3. Understanding How Ethereum Works
    1. Overview of Ethereum
    2. Ethereum accounts
    3. Transactions
    4. Consensus
    5. Timestamp
    6. Nonce
    7. Block time
    8. Forking
    9. Genesis block
    10. Ether denominations
    11. Ethereum virtual machine
    12. Gas
    13. Peer discovery
    14. Whisper and Swarm
    15. Geth
      1. Installing geth
        1. OS X
        2. Ubuntu
        3. Windows
      2. JSON-RPC and JavaScript console
      3. Sub-commands and options
        1. Connecting to the mainnet network
        2. Creating a private network
      4. Creating accounts
        1. Mining
        2. Fast synchronization
    16. Ethereum Wallet
    17. Mist
    18. Weaknesses
      1. Sybil attack
      2. 51% attack
    19. Serenity
      1. Payment and state channels
      2. Proof-of-stake and casper
      3. Sharding
    20. Summary
  4. Writing Smart Contracts
    1. Solidity source files
    2. The structure of a smart contract
    3. Data location
    4. What are the different data types?
      1. Arrays
      2. Strings
      3. Structs
      4. Enums
      5. Mappings
      6. The delete operator
      7. Conversion between elementary types
      8. Using var
    5. Control structures
    6. Creating contracts using the new operator
    7. Exceptions
    8. External function calls
    9. Features of contracts
      1. Visibility
      2. Function modifiers
      3. The fallback function
      4. Inheritance
        1. The super keyword
        2. Abstract contracts
    10. Libraries
      1. Using for
    11. Returning multiple values
    12. Importing other Solidity source files
    13. Globally available variables
      1. Block and transaction properties
      2. Address type related
      3. Contract related
    14. Ether units
    15. Proof of existence, integrity, and ownership contract
    16. Compiling and deploying contracts
    17. Summary
  5. Getting Started with web3.js
    1. Introduction to web3.js
      1. Importing web3.js
      2. Connecting to nodes
      3. The API structure
      4. BigNumber.js
      5. Unit conversion
      6. Retrieving gas price, balance, and transaction details
      7. Sending ether
      8. Working with contracts
      9. Retrieving and listening to contract events
    2. Building a client for an ownership contract
      1. The project structure
      2. Building the backend
      3. Building the frontend
      4. Testing the client
    3. Summary
  6. Building a Wallet Service
    1. Difference between online and offline wallets
    2. hooked-web3-provider and ethereumjs-tx libraries
    3. What is a hierarchical deterministic wallet?
    4. Introduction to key derivation functions
    5. Introduction to LightWallet
      1. HD derivation path
    6. Building a wallet service
      1. Prerequisites
      2. Project structure
      3. Building the backend
      4. Building the frontend
      5. Testing
    7. Summary
  7. Building a Smart Contract Deployment Platform
    1. Calculating a transaction's nonce
    2. Introducing solcjs
      1. Installing solcjs
      2. solcjs APIs
        1. Using a different compiler version
        2. Linking libraries
        3. Updating the ABI
    3. Building a contract deployment platform
      1. The project structure
      2. Building the backend
      3. Building the frontend
      4. Testing
    4. Summary
  8. Building a Betting App
    1. Introduction to Oraclize
      1. How does it work?
      2. Data sources
      3. Proof of authenticity
      4. Pricing
      5. Getting started with the Oraclize API
        1. Setting the proof type and storage location
        2. Sending queries
        3. Scheduling queries
        4. Custom gas
        5. Callback functions
        6. Parsing helpers
        7. Getting the query price
      6. Encrypting queries
        1. Decrypting the data source
      7. Oraclize web IDE
    2. Working with strings
    3. Building the betting contract
    4. Building a client for the betting contract
      1. Projecting the structure
      2. Building the backend
      3. Building the frontend
      4. Testing the client
    5. Summary
  9. Building Enterprise Level Smart Contracts
    1. Exploring ethereumjs-testrpc
      1. Installation and usage
        1. The testrpc command-line application
        2. Using ethereumjs-testrpc as a web3 provider or as an HTTP server
      2. Available RPC methods
    2. What are event topics?
    3. Getting started with truffle-contract
      1. Installing and importing truffle-contract
      2. Setting up a testing environment
      3. The truffle-contract API
        1. The contract abstraction API
          1. Creating contract instances
        2. The contract instance API
    4. Introduction to truffle
      1. Installing truffle
      2. Initializing truffle
      3. Compiling contracts
      4. Configuration files
      5. Deploying contracts
        1. Migration files
        2. Writing migrations
      6. Unit testing contracts
        1. Writing tests in JavaScript
        2. Writing tests in Solidity
          1. How to send ether to a test contract
        3. Running tests
      7. Package management
        1. Package management via NPM
        2. Package management via EthPM
        3. Using contracts of packages within your contracts
        4. Using artifacts of packages within your JavaScript code
        5. Accessing a package's contracts deployed addresses in Solidity
      8. Using truffle's console
      9. Running external scripts in truffle's context
      10. Truffle's build pipeline
        1. Running an external command
        2. Running a custom function
        3. Truffle's default builder
          1. Building a client
      11. Truffle's server
    5. Summary
  10. Building a Consortium Blockchain
    1. What is a consortium blockchain?
    2. What is Proof-of-Authority consensus?
    3. Introduction to parity
      1. Understanding how Aura works
      2. Getting parity running
        1. Installing rust
          1. Linux
          2. OS X
          3. Windows
        2. Downloading, installing and running parity
      3. Creating a private network
        1. Creating accounts
        2. Creating a specification file
        3. Launching nodes
        4. Connecting nodes
      4. Permissioning and privacy
    4. Summary

Product information

  • Title: Building Blockchain Projects
  • Author(s): Narayan Prusty
  • Release date: April 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781787122147