Truffle Quick Start Guide

Book description

Develop, test, and deploy decentralized applications for Ethereum platform

About This Book
  • Build your first Ethereum Dapp with Truffle: the most popular Ethereum development framework
  • Build, compile, and deploy smart contracts in your development environment
  • Embrace Blockchains and utilize it to create new generation of secured and scalable apps
Who This Book Is For

This book is for web developers who are interested in the new world blockchain. Some basic understanding of JavaScript and web services is required. No prior knowledge of Decentralized applications or blockchain is required.

What You Will Learn
  • Understand the fundamentals of Truffle and Web3
  • Build a decentralized application with Truffle, while choosing the correct Ethereum client
  • Connect your Dapp to Ethereum clients including Geth, Parity, and Ganache
  • Migrate and test your Dapp with the correct networks such as Ropsten and Rinkeby
  • Package a decentralized application into a user-friendly product by integrating Truffle with JavaScript frameworks such as Angular, React and Vue
  • Explore tools including Ethereum Package Manager, the Registrar and browser wallets, and exploit third-party smart contract libraries.
  • Evaluate the common migration pitfalls and how to mitigate them
In Detail

Truffle is a world-class development environment, testing framework and asset pipeline for Ethereum, aiming to make life as an Ethereum developer easier.

If you are a web developer wanting to try your hand at developing Dapps with Truffle, then this is the book for you. This book will teach you to write smart contracts and build Dapps with Truffle. You will begin with covering the basics of Truffle, briefly explaining how it integrates Solidity and Web3, in orderto start building a mini decentralized application. Also, you will dive into migration, testing and integrating Truffle with the use of popular JavaScript frameworks. Lastly, you will ship your decentralized application and package it into a product. Moreover, you will go through the best practices in Truffle,so as to increase your proficiency in building Dapps with Truffle.

By the end of the book, you will be able to write smart contracts and build decentralized applications with Truffle on Ethereum blockchains.

Style and approach

An intuitive, step-by-step and engaging guide that will teach you to build a real-world, decentralized application with Truffle.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Truffle Quick Start Guide
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the author
    2. About the reviewer
    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. Code in Action
      4. Conventions used
    4. Get in touch
      1. Reviews
  6. Truffle for Decentralized Applications
    1. Technical requirements
    2. What is Truffle?
    3. Let's build a mini Dapp
      1. Let's build a to-do list
      2. Initializing a Truffle project
      3. Peeping into the folders
      4. Peeping into the root files
      5. Housekeeping before we write code
      6. Writing our first smart contract
      7. Adding an owner
      8. Creating a reward method
      9. Securing your contract with modifiers
      10. Adding a utility method
      11. Wrapping up
      12. Building a user interface
      13. Simple styling
      14. Performing the build steps
      15. Let's write some JavaScript
    4. References
    5. Summary
  7. Web3 and Solidity in Truffle
    1. Technical requirements
    2. What is web3?
      1. Ganache-CLI
    3. Web3 in Truffle
    4. Solidity – a refresher
      1. Data types
        1. Arrays
        2. Structs
        3. Mapping
      2. Visibility specifiers
      3. Functions
      4. Function modifiers
      5. Function types
      6. Events
    5. Summary
  8. Choosing an Ethereum Client for Your Dapp
    1. Technical requirements
    2. Geth, Parity, and Ganache
      1. What is an Ethereum client?
      2. Geth
      3. How does Geth work?
        1. The power of Geth
        2. Common GETH actions
      4. Parity
        1. The power of Parity
        2. Common Parity actions
      5. Ganache-CLI
        1. The power of Ganache-CLI
        2. Common Ganache-CLI actions
    3. Choosing the correct Ethereum client
    4. Truffle and Ethereum clients
      1. Truffle and Geth
      2. Truffle and Parity
      3. Truffle and Ganache-CLI
    5. Summary
  9. Migrating Your Dapp to Ethereum Blockchains
    1. Technical requirements
    2. Let's migrate
      1. Migrating your contracts to Ropsten with Parity
      2. Creating a new Ropsten Parity account
      3. Syncing Parity to Ropsten
      4. Adding funds to our Parity coinbase account
      5. Migrating our contract to Ropsten
      6. Migrating our contract to kovan
    3. Common migration pitfalls
    4. Summary
  10. Truffle and Popular JavaScript Technologies
    1. Technical requirements
    2. Truffle and Angular
      1. angular-truffle-starter-dapp
        1. Peeping into the src folder
        2. Running the starter Dapp
          1. Part 1
          2. Part 2
        3. Diving into Web3Service
        4. MetaCoinService
    3. Truffle and React
      1. The Truffle and React starter
        1. Peeping into the src folder
        2. Diving into the Truffle and React code
    4. Truffle and Node
      1. Running our Truffle and Node application
        1. The node run steps
    5. Summary
  11. Testing Your Dapp
    1. Technical requirements
    2. Writing unit tests with Solidity
      1. Testing the TaskMaster 
    3. Writing unit tests with JavaScript
    4. Testing for Solidity events
    5. Summary
  12. Truffle Gotchas and Best Practices
    1. Gas versus gas limit versus gas price
      1. Gas
      2. Gas price
      3. Gas limit
    2. Sync issues in Geth
    3. Security best practices
    4. Summary
  13. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Truffle Quick Start Guide
  • Author(s): Nikhil Bhaskar
  • Release date: June 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781789132540