Learn Ethereum

Book description

Explore the blockchain-based decentralized platform and understand how Ethereum works with Dapps examples

Key Features

  • Explore the Ethereum ecosystem and understand the latest research on the platform
  • Build decentralized apps (Dapps) using smart contracts and Ethereum with the help of practical examples
  • Learn to make your decentralized applications fast and highly secure

Book Description

Ethereum is a blockchain-based, decentralized computing platform that allows running smart contracts. This book provides a basic overview of how Ethereum works, its ecosystem, mining process, and the consensus mechanism. It also demonstrates a step-by-step approach for building decentralized applications.

This book begins with the very basics of Blockchain technology. Then it dives deep into the Ethereum architecture, framework and tools in its ecosystem. It also provides you an overview of ongoing research on Ethereum, for example, Layer 1 and 2 scaling solution, Stablecoin, ICO/STO/IEO, etc. Next, it explains Solidity language in detail, and provides step-by-step instructions for designing, developing, testing, deploying, and monitoring decentralized applications.

In addition, you’ll learn how to use Truffle, Remix, Infura, Metamask, and many other Ethereum technologies. It’ll also help you develop your own cryptocurrency by creating ERC20, and ERC721 smart contracts from scratch. Finally, we explain private blockchains, and you learn how to interact with smart contracts through wallets.

What you will learn

  • Understand the concepts of blockchain and cryptocurrency
  • Master Ethereum development tools such as Truffle, Remix IDE and Infura
  • Delve into smart contract development
  • Develop DApps frontend using Node.js, React.js, and Web3js API
  • Learn Etherscan and other tools to secure and monitor smart contracts
  • Develop and debug smart contracts by working with Remix
  • Apply Truffle suite to compile, migrate, and unit test smart contracts
  • Explore smart contracts such as ERC20 token and decentralized digital market

Who this book is for

This book is for all developers and architects who want to explore Ethereum blockchain fundamentals and get started with building real-world decentralized applications. Knowledge of an object-oriented programming language such as JavaScript will be useful but not mandatory.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Learn Ethereum
  3. About Packt
    1. Why subscribe?
  4. Contributors
    1. About the authors
    2. About the reviewers
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Section 1: Blockchain and Ethereum Basics
  7. Blockchain and Cryptocurrency
    1. Technical Requirements
    2. Introducing blockchain technology
      1. Decentralized P2P network
      2. How does blockchain work?
    3. Rehashing cryptography
      1. Public key cryptography
      2. Cryptographic hash function
      3. Digital signature
    4. Anatomizing a blockchain consensus mechanism
      1. What is consensus?
      2. Proof-of-work
        1. How PoW works
        2. Targets and difficulty
        3. Incentives and rewards
        4. Double-spend issues
        5. Advantages and disadvantages
      3. Proof-of-stake
      4. Forking
        1. Hard fork
        2. Soft fork
    5. Understanding Bitcoin and cryptocurrency
      1. Bitcoin basics
      2. What is a wallet?
      3. Transactions, UTXO, and account balances
      4. Genesis block and coin supply
      5. How does Bitcoin payment work?
        1. Bitcoin transaction and block structure
        2. Transaction validation and block verification
      6. Limitations in Bitcoin
      7. Altcoins
    6. Ushering in the world of Ethereum
      1. Smart contract
      2. Ethereum Virtual Machine
      3. Account
    7. Summary
  8. Ethereum Architecture and Ecosystem
    1. Technical Requirements
    2. Introducing Ethereum architecture
      1. Ethereum – the world computer
        1. The world of decentralization
    3. Diving deep into Ethereum
      1. Account
        1. Two types of accounts
        2. Externally owned account
        3. Contract account
      2. Transactions and messages
      3. Smart contract
      4. Ether and gas
      5. The Ethereum Virtual Machine
      6. Address and wallet
        1. Addresses in Ethereum
        2. Ethereum wallet
        3. Wallet tools
    4. Understanding mining in Ethereum
      1. Mining and consensus protocol
      2. Ethereum transaction and block structure
      3. Transaction validation and block verification
      4. Shift to proof-of-stake
    5. Working with tools and technologies in Ethereum ecosystem
      1. Ethereum client
      2. The Web3 Server API
      3. DApp development tools
    6. Summary
  9. Deep Research on Ethereum
    1. Technical Requirements
    2. Understanding challenges in distributed systems
      1. The CAP theorem
      2. Horizontal scaling versus vertical scaling
    3. Scaling Ethereum
      1. Blockchain scalability trilemma
      2. Ethereum scaling solutions
        1. Block size
        2. Altcoins
        3. On-chain solutions
        4. Off-chain solutions
        5. ZK-SNARK
      3. State channel with Raiden
      4. Ethereum side chain with Plasma
      5. Ethereum sharding and Casper
      6. PoS consensus in Ethereum
    4. Following up on EVM and lower-level protocol improvements
    5. Implementing Ethereum 2.0 roadmap
    6. Introducing cryptoassets and Ethereum token standards
      1. Initial coin offerings
      2. STO and IEO
      3. Ethereum token standards
        1. Fungible and non-fungible tokens
        2. ERC-20
        3. ERC-721
      4. Stablecoin
        1. Dai stablecoin
      5. Making sense of cryptoeconomics
    7. Working with decentralized data and content storage
      1. Swarm
      2. IPFS
      3. BigchainDB
    8. Decentralized messaging with Whisper
    9. Summary
  10. Section 2: Blockchain Development Cycle
  11. Solidity Fundamentals
    1. Technical Requirements
    2. Introducing Solidity
      1. Tools for the Solidity development environment
        1. Browser-based IDEs
        2. Standalone IDE with Solidity plugins
        3. Command-line development management tools
    3. Learning the fundamental programming structure in Solidity
      1. The layout of a Solidity source file
        1. Pragma
        2. Comments
        3. Import
      2. Structure of a contract
      3. State variables
        1. Built-in data types
        2. User-defined data type
      4. Functions
        1. Input parameters
        2. Output parameters
        3. Access modifiers
        4. The pure, view, and payable functions
        5. Constructor and destructor functions
        6. Fallback function
        7. Function overloading
      5. Function modifiers
      6. Events
      7. Global variables, contextual variables, and functions
    4. Understanding inheritance, abstract contracts, and interfaces
      1. Interface
      2. Abstract contract
      3. Inheritance
        1. Multiple inheritance and the diamond problem
        2. Function overriding
    5. Examining smart contract execution under the hood
    6. Mastering advanced programming concepts in Solidity
      1. Smart contract security
        1. Keep contracts simple and modular
        2. Use the checks-effects-interactions pattern
        3. DoS with block gas limit
        4. Handle errors in external calls
      2. Best practices in smart contracts
        1. Access restriction
        2. State machine
      3. Writing upgradable smart contracts
        1. Contract proxy and delegate
        2. Eternal storage
      4. Economic consideration of smart contract execution
    7. Putting it all together – rental property leasing
    8. Summary
  12. Developing Your Own Cryptocurrency
    1. Technical Requirements
    2. Understanding token standards
    3. Setting up an Ethereum development environment
      1. Working with Truffle
    4. Creating an ERC-20 token
      1. Creating basic token information
      2. Defining and implementing the ERC-20 interface
      3. Assigning an admin role
      4. Working with the whitelist function
      5. Locking and unlocking an account
      6. The mint and burn tokens
    5. Creating ERC 721 token – the DigitalArt token
      1. Designing the decentralized digital art marketplace
      2. Setting up the DigitalArtERC721Token project
      3. Creating the basic token information
      4. Defining and implementing the ERC-721 standard
      5. Defining the art and art transaction struct
      6. Creating a non-fungible digital art token
      7. Implementing the buyArt() function
      8. Implementing the resellArt() function
      9. Implementing the findArt() function
      10. Implementing the findMyArts() function
      11. Implementing the findAllPendingArt() function
      12. Getting all art transactions through getArtAllTxn()
    6. Summary
  13. Section 3: Ethereum Implementations
  14. Smart Contract Development and Test Fundamentals
    1. Technical Requirements
    2. Understanding Remix development fundamentals
      1. Working with the Solidity compiler
      2. Analysis
      3. Testing
      4. Deploying and running transactions
      5. Debugging
    3. Understanding development using Truffle and unit testing
      1. The Truffle console and development features
      2. Running a Truffle migration
      3. Truffle unit testing
      4. Truffle Box
    4. Security testing
      1. Static and dynamic analysis
        1. MythX
        2. Securify
      2. Working with a linter
        1. Working with solhint
    5. Summary
  15. Writing UI for the DApps
    1. Technical requirements
    2. Knowing about DApps
    3. Working with Web3 JavaScript API
    4. Setting up a DApp development environment
      1. Installing Ganache desktop
      2. Creating a development workspace
      3. Setting up the project for our DApp
      4. Deploying a smart contract
      5. Installing MetaMask and connecting to Ganache
      6. Setting MetaMask Ganache accounts
    5. Building frontend UI components
      1. Setting up project dependencies
      2. Getting the instance of a deployed contract
      3. Building a navigation bar
        1. The ART GALLERY page
        2. The PUBLISH YOUR ARTS page
        3. The MY WALLET INFO page
    6. Running the decentralized digital art market DApp
      1. Publishing your art (the first account)
      2. My wallet info (the first account)
      3. Publishing your art (the second account)
      4. My wallet info (the second account)
      5. Buying art (the second account)
      6. Reselling art
    7. Summary
  16. Ethereum Tools and Frameworks
    1. Technical requirements
    2. Understanding the Ethereum development tools and frameworks
      1. Working with Infura
      2. Working with the Infura Ethereum API
      3. Using Remix with Infura
    3. The Ethereum client API
      1. Working with Web3j
    4. Ethereum storage
      1. Knowing the IPFS protocol
      2. Installing IPFS
      3. Starting an IPFS node
      4. Running an IPFS example
        1. Publishing a simple page in the command line
        2. Publishing and querying IPFS via Infura
      5. Working with Swarm
        1. Installing Swarm
        2. Installing Geth
        3. Running an example of Swarm
    5. Ethereum messages – Whisper
      1. Whisper protocol
      2. Whisper envelopes
      3. Whisper message
      4. Whisper example
    6. Popular smart contract libraries
      1. Working with OpenZeppelin
        1. Setting up a dev environment
        2. Access control
        3. Math
        4. Token
        5. Utils
    7. Summary
  17. Section 4: Production and Deployment
  18. Creating an Ethereum Private Chain
    1. Technical requirements
    2. Understanding a private and permissioned blockchain
    3. Setting up a local private Ethereum blockchain
      1. Private blockchains without mining
        1. Setting up the environment
        2. Configuring the custom genesis file
        3. Running Geth
      2. Private blockchains with mining
        1. Setting up an environment
        2. Configuring the custom genesis file
        3. Running Geth
        4. Creating a new account
        5. Mining on a local private network
    4. Using optional flags with new chains
      1. Commands
      2. Ethereum options
      3. Developer chain options
      4. API and console options
      5. Networking options
      6. Transaction pool options
    5. Introducing the popular private blockchains in the industry
      1. Hyperledger
        1. Hyperledger Fabric
        2. Hyperledger Sawtooth
      2. Corda
      3. Quorum
    6. Private blockchains use cases
      1. Financial services
        1. Payments
        2. Audit and assurance
      2. Healthcare
        1. Medical records
        2. Medical costs
        3. Drugs
      3. Food supply chain
    7. Summary
  19. Deployment of Your Smart Contract
    1. Technical requirements
    2. Deploying smart contracts with testnet
      1. Deploying a smart contract to the Goerli testnet with MyCrypto
        1. Creating a MetaMask account
        2. Getting test ether
        3. Deploying the smart contract
        4. Viewing deployed smart contracts on Etherscan
        5. Interacting with the deployed smart contract
      2. Deploying a smart contract to the Ropsten testnet with MyEtherWallet
        1. Accessing or creating a new wallet on MyEtherWallet
        2. Getting test ether
        3. Deploying the smart contract
    3. Monitoring smart contracts
      1. Ethereum developer APIs
      2. Further reading on uncle nodes
    4. Summary
  20. Building Ethereum Wallets
    1. Technical requirements
    2. Understanding the wallet technology
      1. Understanding non-deterministic and deterministic wallets
      2. Mnemonic code words (BIP-39)
      3. Stretching mnemonic code words to the seed of the deterministic wallet
      4. HD wallets (BIP-32)
        1. Deriving a tree of keypairs
        2. Deriving wallet structure
      5. HD wallet path
        1. Multipurpose HD wallets (BIP-43)
        2. Multi-currency and multi-account wallets (BIP-44)
      6. Generating a private key in Ethereum
    3. Creating an Ethereum wallet
      1. Creating a non-deterministic wallet
        1. Viewing the Keystore file generated by the geth command
        2. Creating a non-deterministic wallet with MyCrypto
        3. Creating a non-deterministic wallet with MyEtherWallet
      2. Creating an HD wallet
    4. Working with third-party Ethereum wallets
      1. Wallets on different platforms
      2. Multi-signature wallets
      3. Smart contract wallets
      4. Hot and cold wallets
      5. Transferring funds between wallets
    5. Summary
  21. Section 5: Conclusion
  22. Conclusion
    1. Technical requirements
    2. Facing the challenges of Ethereum and blockchain
      1. Consensus protocol and scalability
      2. UI/UX, usability, and design thinking
      3. Ethereum governance
      4. Government regulations
      5. Mainstream adoption
      6. A few more words about privacy
    3. Glancing over the Ethereum ecosystem
      1. Tools and infrastructure
      2. Decentralized applications
      3. AML and KYC
    4. Emerging technology fusion – blockchain, AI/ML, and IoT
      1. Internet of blockchains
      2. Blockchain meets AI and ML
      3. Smart things on a decentralized network
    5. Meeting the future of Ethereum
    6. Summary
  23. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Learn Ethereum
  • Author(s): Xun Wu, Zhihong Zou, Dongying Song
  • Release date: September 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781789954111