Learn Ethereum: Build your own decentralized applications with Ethereum and smart contracts

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

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.

Author(s): Xun (Brian) Wu, Zhihong Zou and Dongying Song
Edition: 1
Publisher: Packt Publishing
Year: 2019

Language: English
Pages: 523

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