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

Mastering Ethereum

Book Description

If you’re looking to get started with the Ethereum protocol—or are among the many open source developers, integrators, and system administrators already working with this platform—Mastering Ethereum is the definitive book on the topic. Authors Gavin Wood and Andreas Antonopoulos provide everything you need to know about building smart contracts and decentralized autonomous organizations on the Ethereum blockchain.

By bridging the world of cloud computing, grid computing, and blockchains, Ethereum has created a massive decentralized computing platform that many people are calling a "world computer." Ethereum has also spawned a rapidly growing ecosystem of software startups vying to build decentralized applications, known as "dapps".

With this practical guide, you’ll learn how to create markets, store registries of debts or promises, move funds in accordance with instructions given long in the past (like a will or a futures contract), and many other things that have not been invented yet, all without a middle man or counterparty risk.

Discover why IBM, Microsoft, NASDAQ, and other organizations have announced interest and/or development in this Turing-complete decentralized computing platform with Mastering Ethereum.

Table of Contents

  1. Preface
    1. Writing Mastering Ethereum
    2. Intended Audience
    3. Why Are There Bees on the Cover?
    4. Conventions Used in This Book
    5. Code Examples
    6. Using Code Examples
    7. Ethereum Addresses and Transactions in This Book
    8. O’Reilly Safari
    9. How to Contact Us
    10. Contacting the Author
    11. Acknowledgments
      1. Early Release Draft (GitHub Contributions)
  2. Quick Glossary
  3. 1. What is Ethereum?
    1. Compared to bitcoin
    2. Components of a blockchain
    3. Development of Ethereum
    4. The Birth of Ethereum
    5. Ethereum: A general purpose blockchain
      1. Ethereum’s components
      2. Ethereum and Turing Completeness
      3. Turing Completeness as a “feature”
      4. Implications of Turing Completeness
    6. From general purpose blockchains to DApps
      1. Evolving the World Wide Web
    7. Ethereum’s Development Culture
    8. Why learn Ethereum
    9. What this book will teach you
  4. 2. Ethereum Basics
    1. Control and responsibility
    2. Ether currency units
    3. Choosing an Ethereum wallet
    4. Installing MetaMask
    5. Using MetaMask for the first time
    6. Switching Networks
    7. Getting some test ether
    8. Sending ether from MetaMask
      1. Exploring the transaction history of an address
    9. Introducing the world computer
    10. Externally Owned Accounts (EOAs) and Contracts
    11. A simple contract: a test ether faucet
    12. Compiling the Faucet contract
    13. Creating the contract on the blockchain
    14. Interacting with the contract
      1. Viewing the contract address in a block explorer
      2. Funding the contract
      3. Withdrawing from our contract
    15. Conclusion
  5. 3. Ethereum Clients
    1. Should I run a full node?
      1. Full Node Advantages and Disadvantages
      2. Public Testnet Advantages and Disadvantages
      3. Local Instance (TestRPC) Advantages and Disadvantages
    2. Running an Ethereum client
      1. Hardware Requirements for a Full Node
      2. Software Requirements for Building and Running a Node
      3. Go-Ethereum (Geth)
      4. Parity
      5. JSON-RPC Interface
    3. The First Synchronization of the Ethereum Blockchain
    4. Lightweight Ethereum Clients
    5. Mobile (Smartphone) Wallets
    6. Browser wallets
      1. MyEtherWallet (MEW)
      2. MyCrypto
      3. MetaMask
  6. 4. Keys, Addresses
    1. Introduction
      1. Public Key Cryptography and Cryptocurrency
      2. Private Keys
      3. Public Keys
      4. Elliptic Curve Cryptography Explained
      5. Elliptic Curve Arithmetic Operations
      6. Generating a Public Key
      7. Elliptic Curve libraries
    2. Cryptographic Hash Functions
      1. Ethereum’s Cryptographic Hash Function - Keccak-256
      2. Which Hash Function Am I Using?
    3. Ethereum Addresses
    4. Ethereum Address Formats
      1. Inter exchange Client Address Protocol (ICAP)
      2. Hex Encoding with Checksum in Capitalization (EIP-55)
      3. Detecting an error in an EIP-55 encoded address
  7. 5. Wallets
    1. Wallet Technology Overview
      1. Nondeterministic (Random) Wallets
      2. Deterministic (Seeded) Wallets
      3. HD Wallets (BIP-32/BIP-44)
      4. Seeds and Mnemonic Codes (BIP-39)
      5. Wallet Best Practices
      6. Mnemonic Code Words (BIP-39)
      7. Creating an HD Wallet from the Seed
      8. Hierarchical Deterministic Wallets (BIP-32) and paths (BIP-43/44)
  8. 6. Transactions
    1. Structure of Transaction
      1. The transaction nonce
    2. Transaction gas
    3. Transaction recipient
    4. Transaction value and data
    5. Transmitting value to EOAs and contracts
    6. Transmitting a data payload to an EOA or contract
    7. Special transaction: Contract registration
    8. Digital signatures
      1. Elliptic Curve Digital Signature Algorithm (ECDSA)
      2. How Digital Signatures Work
      3. Verifying the Signature
      4. ECDSA Math
      5. Transaction signing in practice
      6. Raw transaction creation and signing
      7. Raw transaction creation with EIP-155
    9. The signature prefix value (v) and public key recovery
    10. Separating signing and transmission (offline signing)
    11. Transaction propagation
    12. Recording in the chain
  9. 7. Tokens
    1. What are tokens?
    2. How are tokens used?
    3. Tokens and fungibility
    4. Counterparty risk
    5. Tokens and intrinsicality
    6. Using tokens: utility or equity
      1. It’s not a duck
      2. Utility tokens: who needs them?
    7. Token Standards
      1. ERC20 Token Standard
      2. Launching our own ERC20 token
      3. Interacting with METoken using the truffle console
      4. Sending ERC20 tokens to contract addresses
      5. Demonstrating the approve & transferFrom workflow
      6. Issues with ERC20 tokens
      7. ERC223 - a proposed token contract interface standard
      8. ERC777 - a proposed token contract interface standard
      9. ERC721 - non-fungible token (deed) standard
    8. Token standards
      1. What are token standards? What is their purpose?
      2. Should you use these standards?
    9. Security by maturity
    10. Extensions to token interface standards
    11. Tokens and ICOs
  10. A. Ethereum Standards
    1. Ethereum Improvement Proposals (EIPs)
    2. Ethereum Request for Comments (ERCs)
    3. Bitcoin Improvement Proposals (BIPs)
      1. Standards from bitcoin used in Ethereum
    4. Table of Most Important EIPs and ERCs
  11. B. Ethereum EVM Opcodes and gas consumption
    1. Table