Hands-On Smart Contract Development with Solidity and Ethereum

Book description

Ready to dive into smart contract development for the blockchain? With this practical guide, experienced engineers and beginners alike will quickly learn the entire process for building smart contracts for Ethereum--the open source blockchain-based distributed computing platform. You'llget up to speed with the fundamentals and quickly move into builder mode.

Kevin Solorio, Randall Kanna, and Dave Hoover show you how to create and test your own smart contract, create a frontend for users to interact with, and more. It's the perfect resource for people who want to break into the smart contract field but don't know where to start.

In four parts, this book helps you:

  • Explore smart contract fundamentals, including the Ethereum protocol, Solidity programming language, and the Ethereum Virtual Machine
  • Dive into smart contract development using Solidity and gain experience with Truffle framework tools for deploying and testing your contracts
  • Use Web3 to connect your smart contracts to an applicationso users can easily interact with the blockchain
  • Examine smart contract security along with free online resources for smart contract security auditing

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Mastering Ethereum
    2. ConsenSys Academy
    3. B9 Academy
    4. Conventions Used in This Book
    5. Using Code Examples
    6. O’Reilly Online Learning
    7. How to Contact Us
    8. Acknowledgments
  2. I. Intro to the Ethereum Blockchain
  3. 1. Blockchain Concepts
    1. A Brief History
    2. The Character of a Blockchain
      1. Decentralized Networks
      2. Consensus Protocols
      3. Transaction Processing
      4. Transaction Finality
      5. Hard Forks
    3. Ethereum Fundamentals
      1. Ether and Gas
      2. Accounts
      3. Contracts
      4. Blocks and Transactions
      5. What Time Is It?
      6. Signing Transactions
    4. Summary
  4. 2. Decentralized Applications
    1. Tokens
      1. ERC-20
      2. Non-Fungible Token (ERC-721)
    2. Supply Chain
    3. Permanent Records
    4. Evaluating Blockchain for Your Application
      1. Verifiable
      2. Transparent
      3. Resilient
    5. Summary
  5. 3. Before We Get Started
    1. Ethereum Clients
      1. Installing Parity
    2. Installing MetaMask
    3. Installing Node.js
      1. Ubuntu Installation (Including Windows WSL Ubuntu)
      2. Mac Installation
    4. Installing the Truffle Suite
      1. Truffle
      2. Ganache
    5. Summary
  6. II. Developing Smart Contracts
  7. 4. Our First Smart Contract
    1. Setup
    2. Our First Test
    3. Saying Hello
    4. Making Our Contract Dynamic
    5. Making the Greeter Ownable
    6. Summary
  8. 5. Deploying and Interacting with Contracts
    1. Contract Compilation and Deployment
      1. Deployment Process
    2. Setting Up the UI
    3. Deploying to Ganache
    4. Deploying to Goerli with Parity
    5. Deploying to Rinkeby with Infura
    6. Summary
  9. 6. The Fundraiser Application
    1. Application Overview
    2. Creating the Project
    3. Initializing Fundraisers
      1. Setting the Beneficiary and Custodian
    4. Editing the Beneficiary
    5. Making Donations
      1. Structs
      2. Mappings
      3. Donation Tests
      4. myDonations
      5. Fundraiser Totals
      6. Events
    6. Withdrawing Funds
    7. Fallback Functions
    8. Summary
  10. 7. FundraiserFactory
    1. Migrating Our FundraiserFactory
    2. Creating Fundraisers
    3. Viewing Available Fundraisers
      1. Testing Pagination When Empty
      2. Testing the Limit
      3. Testing the Offset
    4. Setting Up the UI
    5. Summary
  11. III. Interacting with Our Smart Contracts Through Web3
  12. 8. What Is Web3?
    1. The Frontend, Web3, and the Blockchain
    2. Web3 Methods
      1. getAccounts()
      2. getBlockNumber()
      3. getBalance()
      4. sendTransaction()
      5. Providers
      6. Promises with Web3
      7. MetaMask for Web3 Injection
      8. Send (State Updates/Write)
      9. Call (Reads)
    3. Summary
  13. 9. Connecting the UI to Our Contracts
    1. Why React?
      1. Dev Setup
    2. Truffle
      1. React Truffle Box Setup
      2. Importing our Greeter Contracts
      3. Adding Our Greeter Contract Functionality
      4. Setting Our Greeting Through React
    3. Summary
  14. 10. Our Larger DApp
    1. Starting with React Truffle Box
      1. Fundraiser Setup
      2. React Routing
    2. React and Material UI
      1. Creating Our New Fundraiser Page View
      2. Displaying the Current Fundraisers List
    3. Summary
  15. 11. Finishing Our Fundraiser UI
    1. Adding Detailed Information About Each Fundraiser
      1. Implementing a Material UI Dialog
    2. Accepting a Donation with React
      1. Testing a Donation
    3. Displaying the Current ETH Exchange Rate
    4. Generating a Donation Receipt for Our User
    5. Handling a Withdrawal from Our Contract
      1. Adding Edit Beneficiary to the Contract
    6. Summary
  16. IV. Securing Your Smart Contracts
  17. 12. Smart Contract Security
    1. Why Do We Need to Worry About Security?
    2. Types of Smart Contract Vulnerabilities
      1. Unprotected Function
      2. Transaction Ordering Dependence
      3. Integer Overflow and Underflow
      4. Reentrancy
      5. Block Gas Limit
      6. Timestamp Dependence
      7. And Many More
    3. Preparing Your Contract for an External Audit
      1. External Auditing
      2. Auditing Companies
      3. Solidified
    4. Free Auditing Resources
    5. Growing Your Auditing Skills
    6. Summary
  18. Index

Product information

  • Title: Hands-On Smart Contract Development with Solidity and Ethereum
  • Author(s): Kevin Solorio, Randall Kanna, David H. Hoover
  • Release date: November 2019
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781492045267