Building Blockchain Apps, 1st edition

Published by Addison-Wesley Professional (November 26, 2019) © 2020

  • Michael Juntao Yuan
Products list
  • Available for purchase from all major ebook resellers, including InformIT.com
Products list

Details

  • A print text
  • Free shipping
  • Also available for purchase as an ebook from all major ebook resellers, including InformIT.com

This product is expected to ship within 3-6 business days for US and 5-10 business days for Canadian customers.

Building on his pioneering experience, Michael Yuan introduces today’s most popular blockchain development paradigm, Ethereum Smart Contract programming. Yuan guides you through working with Dapps, ERC20 tokens, programming for ICOs, and more. Next, he introduces next-generation Tendermint / Cosmos programming models and software architectures that overcome key limitations of previous blockchain environments, reducing congestion and enabling unprecedented scalability. Finally, he introduces potential blockchain applications in key sectors, including Peer-to-Peer (P2P) Finance, Exchanges, and Healthcare.

Foreword xvii
Acknowledgments xix
About the Author xxi


Part I: Introduction 1

Chapter 1: An Introduction to Blockchain 3

The Blockchain 3
The Collaborative Ledger 4
Cryptocurrency 5
Smart Contracts 5
A Trustless Network 6
New Ways of Collaborating 7
The Fat Protocol 7
In Code We Trust 8
Conclusion 9

Chapter 2: Reaching Consensus 11
What Is Blockchain Consensus? 11
Proof of Work (PoW) 12
Proof of Stake (PoS) 12
Delegated Proof of Stake (DPoS) 14
Conclusion 14

Chapter 3: Your First Blockchain App 15
Smart Contract 16
Front-End HTML 19
JavaScript and web3.js 19
In Action 21
Share Your Dapp 22
Conclusion 22

Part II: An Introduction to Ethereum 23

Chapter 4: Getting Started 25

The BUIDL Way 26
The Hard Way 29
Conclusion 41

Chapter 5: Concepts and Tools 43
Ethereum Wallet and Basic Concepts 43
Etherscan 45
The TestRPC 46
Interacting with Ethereum via GETH 48
Interacting with Ethereum via web3 49
Running an Ethereum Node 50
Running a Private Ethereum Network 51
Conclusion 53

Chapter 6: Smart Contracts 55
“Hello, World!” Again 55
Learning Smart Contract Programming 57
Building and Deploying the Smart Contract 59
Calling Smart Contract Functions 65
A New Language 68
Conclusion 72

Chapter 7: Decentralized Applications (Dapps) 73
Dapp Stack 74
Dapp Showcases 76
Conclusion 79

Chapter 8: Alternatives to Dapps 81
JavaScript 81
Python and Others 85
Conclusion 86

Part III: Ethereum in Depth 87

Chapter 9: Inside Ethereum 89

What Is Blockchain State? 89
Ethereum State 92
Trie (or Tree) 93
Trie Structure in Ethereum 98
Analyzing the Ethereum Database 100
Conclusion 104

Chapter 10: Blockchain Data Services 105
Blockchain Explorers 105
Harvesting Data 109
Query Interface 115
What’s Next? 119
Conclusion 120

Chapter 11: Smart Contract Search Engine 121

Introduction to the Smart Contract Search Engine 121
Getting Started with a Smart Contract Search Engine 123
The FairPlay Dapp Example 128
Use Cases 131
Conclusion 132

Chapter 12: Smart Contract Security and Best Practices 133
Major Ethereum Smart Contract Hacks and Vulnerabilities 134
Best Practices for Securing Smart Contracts 141
Conclusion 143

Chapter 13: The Future of Ethereum 145
Ethereum 1.0 146
Beyond Ethereum 1.0 150
Ethereum 2.0 152
Delivery Phases of Ethereum 2.0 154
Post–Ethereum 2.0 Innovation 155
Conclusion 155

Part IV: Building Application Protocols 157

Chapter 14: Extending the Ethereum Protocol 159

Fully Compatible, Yet Faster 160
Smart Enhancements to the EVM 160
Safety First 165
Conclusion 165

Chapter 15: Extending Ethereum Tools 167
Smart Contract Tools 168
Dapp Tools 175
Conclusion 178

Chapter 16: Example Dapps 179
Case Study 1: Valentines 179
Case Study 2: WeBet 184
Conclusion 201

Chapter 17: Business Rules and Contracts 203
An Example 204
Rules Language 206
More Business Examples 210
Conclusion 214

Chapter 18: Building an Application-Specific EVM 215

Using libENI Functions 216
Writing a libENI Function 222
Deploying the libENI Function 224
Conclusion 226

Part V: Building Your Own Blockchain 227

Chapter 19: Getting Started with Tendermint 229

How It Works 229
It Works as Follows 231
Set Up a Node 231
Set Up a Network 235
Conclusion 236

Chapter 20: The Business Logic 237
The Protocol 238
A Sample Application 240
Java Implementation 242
GO Implementation 247
The Cosmos SDK 250
Conclusion 252

Chapter 21: Creating a Blockchain Client 253
Overview of the Approach 254
The Sample Application 255
PHP 256
Java 258
Conclusion 260

Part VI: Cryptoeconomics 261

Chapter 22: The Cryptoeconomics of Token Design 263

Network Utility Tokens 263
Application Utility Tokens 266
Security Tokens 266
Token Valuation 267
Advanced Topics 271
Conclusion 274

Chapter 23: Initial Coin Offerings 275
A Brief History 275
Utility of an ICO 276
ICO vs. Traditional Equity Financing 278
Evaluating an ICO Project 280
ICO Participation Risk 282
Conclusion 283

Chapter 24: Cryptocurrency Exchanges 285
Exchange Types 285
Decentralization 287
Products and Services 288
Conclusion 289

Appendix: Getting Started with CyberMiles 291


Index 295

Need help? Get in touch