Ethereum Cookbook

Book description

Mine Ether, deploy smart contracts, tokens, and ICOs, and manage security vulnerabilities of Ethereum

Key Features

  • Build end-to-end decentralized Ethereum apps using Truffle, Web3, and Solidity
  • Explore various solution-based recipes to build smart contracts and foolproof decentralized applications
  • Develop decentralized marketplaces from scratch, build wallets, and manage transactions

Book Description

Ethereum and Blockchain will change the way software is built for business transactions. Most industries have been looking to leverage these new technologies to gain efficiencies and create new business models and opportunities.

The Ethereum Cookbook covers various solutions such as setting up Ethereum, writing smart contracts, and creating tokens, among others. You'll learn about the security vulnerabilities, along with other protocols of Ethereum.

Once you have understood the basics, you'll move on to exploring various design decisions and tips to make your application scalable and secure. In addition to this, you'll work with various Ethereum packages such as Truffle, Web3, and Ganache.

By the end of this book, you'll have comprehensively grasped the Ethereum principles and ecosystem.

What you will learn

  • Efficiently write smart contracts in Ethereum
  • Build scalable distributed applications and deploy them
  • Use tools and frameworks to develop, deploy, and test your application
  • Use block explorers such as Etherscan to find a specific transaction
  • Create your own tokens, initial coin offerings (ICOs), and games
  • Understand various security flaws in smart contracts in order to avoid them

Who this book is for

The Ethereum Cookbook is for you if you are a software engineer, Blockchain developer, or research scientist who wants to build smart contracts, develop decentralized applications, and facilitate peer-to-peer transaction. It is assumed that you are familiar with Blockchain concepts and have sound knowledge of JavaScript.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Ethereum Cookbook
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. Packt.com
  5. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  6. 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
  7. Getting Started
    1. Introduction
    2. Choosing a client for Ethereum
      1. Getting ready
      2. How to do it...
        1. Geth
        2. Parity
      3. There's more...
    3. Setting up a node and participating in a network
      1. Getting ready
      2. How to do it...
    4. Working with the JavaScript console
      1. Getting ready
      2. How to do it...
      3. There's more...
    5. Saving time and money with INFURA
      1. How to do it...
      2. There's more...
    6. Creating your own private Ethereum network
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    7. Creating a blockchain network for development
      1. Getting ready
      2. How to do it...
      3. There's more...
    8. Using Azure Ethereum as a service
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Using MetaMask and other wallets
      1. Getting ready
      2. How to do it...
        1. MetaMask
        2. MyCrypto
        3. Ethereum wallet–Mist
    10. Using block explorer
      1. How to do it…
      2. There's more...
    11. Understanding everything about accounts
      1. Getting ready
      2. How to do it...
      3. There's more…
    12. Installing a solidity compiler
      1. Getting ready
      2. How to do it…
      3. There's more…
  8. Smart Contract Development
    1. Introduction
    2. Choosing an IDE wisely
      1. How to do it...
      2. There's more...
    3. Writing your first smart contract
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Testing your contract with Remix
      1. How to do it...
      2. There's more...
    5. Static and dynamic types in solidity
      1. Getting ready
      2. How to do it...
      3. There's more...
    6. Constructor and fallback functions
      1. How to do it...
        1. Constructor
        2. Fallback function
    7. Working with struct and enum
      1. How to do it...
        1. Structs 
        2. Enums
    8. Control structures in Solidity
      1. How to do it...
    9. Writing functions in solidity
      1. How to do it...
      2. There's more...
    10. Deciding between arrays and mappings
      1. How to do it...
        1. Arrays
        2. Mapping
    11. Where to use function modifiers
      1. How to do it...
    12. Using visibility modifiers efficiently
      1. How to do it...
    13. Essential events – EVM logger
      1. Getting ready
      2. How to do it...
    14. Using storage and memory efficiently
      1. How to do it...
      2. There's more...
    15. Compiling your contract with the solc compiler
      1. Getting ready
      2. How to do it...
      3. There's more...
    16. Deploying contracts using geth
      1. Getting ready
      2. How to do it...
      3. There's more...
  9. Interacting with the Contract
    1. Introduction
    2. Installing and configuring web3.js
      1. Getting ready
      2. How to do it...
    3. Using MetaMask as an injected provider
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Managing accounts and sending transactions
      1. Getting ready
      2. How to do it...
    5. Compiling and deploying your smart contract
      1. Getting ready
      2. How to do it...
      3. There's more...
    6. Reading data from smart contracts
      1. Getting ready
      2. How to do it...
    7. Writing data into a smart contract
      1. Getting ready
      2. How to do it...
      3. There's more...
    8. Watching events from your DApp
      1. Getting ready
      2. How to do it...
    9. Sending a raw transaction
      1. Getting ready
      2. How to do it...
      3. There's more...
    10. Batch requests using web3.js
      1. Getting ready
      2. How to do it...
    11. Interacting with Ethereum using JSON-RPC
      1. Getting ready
      2. How to do it...
    12. Other ways to interact with your contract
      1. Getting ready
      2. How to do it...
        1. Nethereum
        2. Web3J
  10. The Truffle Suite
    1. Introduction
    2. Installing and configuring the Truffle framework
      1. Getting ready
      2. How to do it...
    3. Making use of Truffle boxes
      1. Getting ready
      2. How to do it...
      3. There's more...
    4. Compiling smart contracts
      1. Getting ready
      2. How to do it...
    5. Advanced Truffle configuration
      1. Getting ready
      2. How to do it...
    6. Migration and deployment in Truffle
      1. Getting ready
      2. How to do it...
    7. Interacting with your contract
      1. Getting ready
      2. How to do it...
      3. There's more...
    8. Debugging a smart contract using Truffle
      1. Getting ready
      2. How to do it...
    9. Writing tests for smart contracts
      1. Getting ready
      2. How to do it...
        1. Writing tests in JavaScript
        2. Writing tests in Solidity
    10. Building DApps and APIs using Truffle
      1. Getting ready
      2. How to do it...
    11. Package management in Truffle
      1. Getting ready
      2. How to do it...
        1. EthPM
        2. npm
      3. There's more...
    12. Getting started with Drizzle
      1. Getting ready
      2. How to do it...
      3. There's more...
    13. Using HD wallet in Truffle
      1. Getting ready
      2. How to do it...
  11. Tokens and ICOs
    1. Introduction
    2. Creating a basic ERC20 token in Ethereum
      1. Getting ready
      2. How to do it…
      3. There's more…
    3. Transferring tokens between accounts
      1. Getting ready
      2. How to do it...
      3. There's more…
    4. Delegating other accounts to spend your token
      1. Getting ready
      2. How to do it…
      3. There's more…
    5. Creating a token that can be minted
      1. Getting ready
      2. How to do it…
    6. Creating a token that can be burnt
      1. Getting ready
      2. How to do it…
      3. There's more…
    7. Creating an ERC223 token
      1. Getting ready
      2. How to do it…
    8. Building your own Initial Coin Offering
      1. Getting ready
      2. How to do it…
    9. Adding features to the ICO contract
      1. Getting ready
      2. How to do it…
      3. There's more…
    10. Providing bonus tokens to investors
      1. Getting ready
      2. How to do it…
      3. There's more…
    11. Whitelisting users for the crowdsale
      1. Getting ready
      2. How to do it…
      3. There's more…
    12. Accepting crypto payments for the crowdsale
      1. Getting ready
      2. How to do it…
        1. MetaMask
        2. Shapeshift
        3. BTC Relay
    13. Creating a wallet that supports all ERC20 tokens
      1. Getting ready
      2. How to do it…
      3. There's more...
  12. Games and DAOs
    1. Introduction
    2. Creating a non-fungible token
      1. Getting ready
      2. How to do it…
      3. There's more…
    3. Asset tracking and movement
      1. Getting ready
      2. How to do it…
    4. Creating a basic game on Ethereum
      1. Getting ready
      2. How to do it…
    5. Building a decentralized lottery on Ethereum
      1. Getting ready
      2. How to do it…
    6. Selecting a winner based on the ticket number
      1. Getting ready
      2. How to do it…
    7. Sharing dividends among investors
      1. Getting ready
      2. How to do it…
    8. Affiliating programs to attract more users
      1. Getting ready
      2. How to do it…
  13. Advanced Solidity
    1. Introduction
    2. Handling errors properly in solidity
      1. Getting ready
      2. How to do it...
        1. require()
        2. revert()
        3. assert()
    3. Abstract and interface contracts
      1. Getting ready
      2. How to do it...
        1. Abstract contracts
        2. Interface contracts
    4. Managing contracts from other contracts
      1. Getting ready
      2. How to do it...
      3. There's more...
    5. Contract inheritance in solidity
      1. Getting ready
      2. How to do it...
    6. Creating libraries in solidity
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    7. Mathematical and cryptographic functions in solidity
      1. Getting ready
      2. How to do it...
      3. There's more...
    8. Creating upgradable smart contracts
      1. Getting ready...
      2. How to do it...
      3. How it works...
    9. Fetching data from APIs using solidity
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    10. Function as a type in solidity
      1. Getting ready
      2. How to do it...
    11. Understanding solidity assembly
      1. Getting ready
      2. How to do it...
      3. There's more...
    12. Implementing multisig wallets in solidity
      1. Getting ready
      2. How to do it...
  14. Smart Contract Security
    1. Introduction
    2. Integer overflow and underflow
      1. Getting ready
      2. How to do it...
      3. There's more...
    3. Re-entrancy attack
      1. Getting ready
      2. How to do it...
    4. The parity hack
      1. Getting ready
      2. How to do it...
    5. Forcing Ether to a contract
      1. Getting ready
      2. How to do it...
      3. There's more...
    6. Use of private variables
      1. Getting ready
      2. How to do it...
    7. Transaction-Ordering Dependence (TOD)
      1. Getting ready
      2. How to do it...
    8. Call to the unknown
      1. Getting ready
      2. How to do it...
    9. DoS using loops
      1. Getting ready
      2. How to do it...
    10. Security analysis tools for solidity
      1. Getting ready
      2. How to do it...
    11. Uninitialized storage pointer in solidity
      1. Getting ready
      2. How to do it...
    12. Best practices in solidity
      1. How to do it...
  15. Design Decisions
    1. Introduction
    2. Serverless architecture for DApps
      1. Getting ready
      2. How to do it...
    3. Implementing an application-specific wallet
      1. Getting ready
      2. How to do it…
    4. What if you find a bug after deployment?
      1. Getting ready
      2. How to do it…
    5. Generating random numbers in Solidity
      1. Getting ready
      2. How to do it…
    6. Keeping contracts simple, modular, and up to date
      1. Getting ready
      2. How to do it…
    7. Implementing user authentication in Ethereum
      1. Getting ready
      2. How to do it…
  16. Other Protocols and Applications
    1. Introduction
    2. Registering on Ethereum Name Service
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Whisper–communication protocol for DApps
      1. Getting ready
      2. How to do it…
    4. Swarm–distributed storage platform
      1. Getting ready
      2. How to do it…
    5. Watching Bitcoin transactions using BTCRelay
      1. Getting ready
      2. How to do it…
    6. Scheduling Ethereum transactions using an alarm clock
      1. Getting ready
      2. How to do it…
    7. Using the openzeppelin library
      1. Getting ready
      2. How to do it…
  17. Miscellaneous
    1. Introduction
    2. Using Vyper to write smart contracts
      1. Getting ready
      2. How to do it...
      3. There's more...
    3. Debugging smart contracts with Remix
      1. Getting ready
      2. How to do it...
    4. Deploying contracts using Remix
      1. Getting ready
      2. How to do it...
    5. Generating documentation for solidity code
      1. Getting ready
      2. How to do it...
    6. Writing better code with the help of a linter
      1. Getting ready
      2. How to do it...
    7. Sharing solidity code with others
      1. Getting ready
      2. How to do it...
  18. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Ethereum Cookbook
  • Author(s): Manoj P R
  • Release date: August 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781789133998