Mastering Blockchain Unlocking the Power of Cryptocurrencies, Smart Contracts, and Decentralized Applications (Lorne Lantz, Daniel Cawrey) (Z-Library)

Author: Lorne Lantz, Daniel Cawrey

教育

The future will be increasingly distributed. As the publicity surrounding Bitcoin and blockchain has shown, distributed technology and business models are gaining popularity. Yet the disruptive potential of this technology is often obscured by hype and misconception. This detailed guide distills the complex, fast moving ideas behind blockchain into an easily digestible reference manual, showing what's really going on under the hood. Finance and technology pros will learn how a blockchain works as they explore the evolution and current state of the technology, including the functions of cryptocurrencies and smart contracts. This book is for anyone evaluating whether to invest time in the cryptocurrency and blockchain industry. Go beyond buzzwords and see what the technology really has to offer. Learn why Bitcoin was fundamentally important in blockchain's birth Learn how Ethereum has created a fertile ground for new innovations like Decentralized Finance (DeFi), Non-Fungible Tokens (NFTs) and Flash Loans Discover the secrets behind cryptocurrency prices and different forces that affect the highly volatile cryptocurrency markets Learn how cryptocurrencies are used by criminals to carry out nefarious activities Discover how enterprise and governments are leveraging the blockchain including Facebook Understand the challenges of scaling and forking a blockchain Learn how different blockchains work Learn the language of blockchain as industry terms are explained

📄 File Format: PDF
💾 File Size: 16.6 MB
47
Views
0
Downloads
0.00
Total Donations

📄 Text Preview (First 20 pages)

ℹ️

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

📄 Page 1
Lorne Lantz & Daniel Cawrey Mastering Blockchain Unlocking the Power of Cryptocurrencies and Smart Contracts
📄 Page 2
(This page has no text content)
📄 Page 3
Praise for Mastering Blockchain Blockchain can be a daunting and elusive subject matter, especially for those who see the vast potential in this incredible technology. Mastering Blockchain brings within one’s grasp a solid foundation of understanding, allowing for immediate actionable learning. This is in large part due to the incredible and nuanced understanding both Daniel and Lorne have earned through years in this space, as well as their active engagements with many in the community. —Dr. Jeff Flowers, Professor, CSM VP, Decentralization Foundation (d24n.org) An excellent book which is easily digestible for beginners and crypto natives. Covers a wide scope of topics, including underlying blockchain fundamentals, crypto market infrastructure, regulations, and many others. Highly recommended. —Gavin Low, Investor Mastering Blockchain presents the history, technical fundamentals, and themes of blockchain in an easy-to-comprehend way. Technical and nontechnical entrants to the field will both find this an invaluable resource for getting up to speed on the broad range of topics in this fast-moving space. —Aaron Caswell, Expert Blockchain Engineer Get down in the trenches with Lorne and Daniel and find out what’s really inside Bitcoin, Ethereum, altcoin, and other blockchains and forks. —Karen Kilroy, CEO, Kilroy Blockchain Corporation
📄 Page 4
Mastering Blockchain goes from the basics to using blockchain in real-life implementations in enterprise-grade environments. —Jorge Lesmes, Global Head of Blockchain at everis (an NTT Data company) Daniel and Lorne cover an exceptionally broad range of topics in the blockchain universe with clarity. Mastering Blockchain is a terrific starting place for those trying to gain a comprehensive view of the incredible impact of this technology on the world. —Jeremy Allaire, CEO Circle Internet Financial Cofounder, Centre USD Stablecoin Consortium As someone who teaches blockchain, this book would be a great accompaniment to a course, providing a much more robust offering than almost anything I have come across. —Dr. Jimmie Lenz, Executive Director, Master of Engineering in FinTech and Master of Engineering in Cybersecurity, Pratt School of Engineering at Duke University After years of hype, pipe-dreams, and snake-oil, we now have a balanced, sensible, and comprehensive book on the essentials of blockchain technology. Mastering Blockchain is the O’Reilly book that IT professionals need in order to figure out where and how to use blockchain in serious production applications. —John Wolpert, Global Product Executive, Consensys Cofounder, IBM Blockchain Mastering Blockchain has managed to compile a vast amount of domain-specific knowledge into an easily understandable, concise reference. This book will be provided as reference material at Bitaccess for new hires to gain a quick, highly detailed, and accurate technical overview of the blockchain sector. —Moe Adham, CEO, Bitcoin ATM provider Bitaccess
📄 Page 5
Lorne Lantz and Daniel Cawrey Mastering Blockchain Unlocking the Power of Cryptocurrencies, Smart Contracts, and Decentralized Applications Boston Farnham Sebastopol TokyoBeijing
📄 Page 6
978-1-492-05470-2 [LSI] Mastering Blockchain by Lorne Lantz and Daniel Cawrey Copyright © 2021 Lorne Lantz and Daniel Cawrey. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com. Acquisitions Editor: Michelle Smith Development Editor: Corbin Collins Production Editor: Christopher Faucher Copyeditor: Rachel Head Proofreader: Piper Editorial, LLC Indexer: Ellen Troutman-Zaig Interior Designer: David Futato Cover Designer: Karen Montgomery Illustrator: Kate Dullea November 2020: First Edition Revision History for the First Edition 2020-11-13: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781492054702 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Mastering Blockchain, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. The views expressed in this work are those of the authors, and do not represent the publisher’s views. While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
📄 Page 7
Table of Contents Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii 1. Origins of Blockchain Technology. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Electronic Systems and Trust 1 Distributed Versus Centralized Versus Decentralized 2 Bitcoin Predecessors 7 DigiCash 7 E-Gold 8 Hashcash 8 B-Money 9 Bit Gold 9 The Bitcoin Experiment 10 The 2008 Financial Crisis 10 The Whitepaper 11 Introducing the Timestamp Server 13 Storing Data in a Chain of Blocks 13 Bringing Bitcoin to Life 17 Compelling Components 17 Achieving Consensus 18 An Early Vulnerability 20 Adoption 21 Summary 22 2. Cryptocurrency Fundamentals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Public and Private Keys in Cryptocurrency Systems 24 The UTXO Model 25 Transactions 26 v
📄 Page 8
The Merkle Root 28 Signing and Validating Transactions 30 The Coinbase Transaction 31 Bitcoin Transaction Security 31 Hashes 33 Block Hashes 34 Custody: Who Holds the Keys 36 Wallet Types: Custodial Versus Noncustodial 36 Wallet Type Variations 37 Security Fundamentals 39 Recovery Seed 40 Mining 41 Mining Is About Incentives 42 Block Generation 43 Consensus 44 Proof-of-Work 44 Proof-of-Stake 51 Other Concepts for Consensus 53 Stakeholders 54 Brokerages 55 Exchanges 55 Custody 56 Analytics 56 Information 57 Summary 57 3. Forks and Altchains. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Bitcoin Improvement Proposals 59 Understanding Forks 61 Contentious Hard Forks 62 The Bitcoin Cash Fork 65 Altcoins 67 Litecoin 68 More Altcoin Experiments 69 “2.0” Chains 70 NXT 70 Counterparty 70 Privacy-Focused Cryptocurrencies 71 Dash 71 Monero 71 Zcash 71 vi | Table of Contents
📄 Page 9
Ripple and Stellar 72 Ripple 72 Stellar 73 Scaling Blockchains 73 SegWit 74 Lightning 75 Other Altchain Solutions 76 The Ethereum Classic Fork 77 Summary 78 4. The Evolution to Ethereum. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Improving Bitcoin’s Limited Functionality 79 Colored Coins and Tokens 80 Mastercoin and Smart Contracts 80 Understanding Omni Layer 80 Ethereum: Taking Mastercoin to the Next Level 84 Ether and Gas 85 Use Cases: ICOs 86 Decentralized Autonomous Organizations 87 Key Organizations in the Ethereum Ecosystem 88 Decentralized Applications (Dapps) 89 Use Cases 90 Challenges in Developing Dapps 90 Deploying and Executing Smart Contracts in Ethereum 91 The Ethereum Virtual Machine 92 Gas and Pricing 99 Interacting with Code 101 Summary 101 5. Tokenize Everything. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Tokens on the Ethereum Platform 105 Fungible and Nonfungible Tokens 105 Is a Token Necessary? 106 Airdrops 107 Different Token Types 107 Understanding Ethereum Requests for Comment 108 ERC-20 108 ERC-721 112 ERC-777 114 ERC-1155 116 Multisignature Contracts 116 Table of Contents | vii
📄 Page 10
Decentralized Exchange Contracts 119 Summary 121 6. Market Infrastructure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Evolution of the Price of Bitcoin 123 The Role of Exchanges 125 Order Books 126 Slippage 128 Depth Charts 129 Jurisdiction 129 Wash Trading 131 Whales 131 Derivatives 133 Cryptocurrency Market Structure 134 Arbitrage 135 Counterparty Risk 135 Market Data 138 Analysis 139 Fundamental Cryptocurrency Analysis 140 Technical Cryptocurrency Analysis 142 Arbitrage Trading 143 Timing and Managing Float 144 Float Configuration 1 144 Float Configuration 2 145 Float Configuration 3 146 Regulatory Challenges 146 Banking Risk 147 Exchange Risk 147 Basic Mistakes 148 Exchange APIs and Trading Bots 148 Open Source Trading Tech 151 Rate Limiting 151 REST Versus WebSocket 152 Testing in a Sandbox 152 Market Aggregators 152 Summary 152 7. Decentralizing Finance and the Web. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 Redistribution of Trust 155 Identity and the Dangers of Hacking 155 Wallets 156 viii | Table of Contents
📄 Page 11
Private Keys 157 Naming Services 157 Decentralizing Finance 158 Important Definitions 158 Stablecoins 160 DeFi Services 162 Lending 163 Savings 163 Derivatives 163 Decentralized Exchanges 164 Decentralized Versus Centralized Exchanges 164 Flash Loans 173 Creating a Flash Loan Contract 174 Deploying the Contract 176 Executing a Flash Loan 177 Flash Loans for Arbitrage 180 The Fulcrum Exploit 180 Privacy 182 Zero-Knowledge Proof 183 Zcash 186 Ring Signatures 186 Web 3.0 186 Summary 187 8. Catch Me If You Can. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 The Evolution of Crypto Laundering 190 FinCEN Guidance and the Beginning of Regulation 192 The FATF and the Travel Rule 194 Skirting the Laws 194 Avoiding Scrutiny: Regulatory Arbitrage 196 Malta 196 Singapore 197 Hong Kong 197 Bahamas 198 Crypto-Based Stablecoins 199 NuBits 199 Digix 199 Basis 200 Tether 200 Initial Coin Offerings 200 Founder Intentions 201 Table of Contents | ix
📄 Page 12
Token Economics 202 Whitepaper 202 Exchange Hacks 203 Mt. Gox 203 Bitfinex 205 Coincheck 206 NiceHash 206 Other Hacks 206 Bloomberg TV BTC Stolen 206 EtherDelta Redirection 206 CryptoLocker and Ransomware 207 SIM Swapping 207 Summary 209 9. Other Blockchains. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 What Are Blockchains Good For? 211 Databases and Ledgers 213 Decentralization Versus Centralization 214 Participants 214 Key Properties of Distributed Verifiable Ledgers 214 Ethereum-Based Privacy Implementations 215 Nightfall 215 Quorum 215 Enterprise Implementations 215 Hyperledger 216 Corda 216 DAML 219 Blockchain as a Service 220 Banking 221 The Royal Mint 221 Banque de France 221 China 222 US Federal Reserve 222 JPMorgan 223 Permissioned Ledger Uses 223 IT 223 Banking 223 Central Bank Digital Currencies 224 Legal 224 Gaming 224 Health Care 225 x | Table of Contents
📄 Page 13
Internet of Things 225 Payments 226 Libra 226 The Libra Association 226 Borrowing from Existing Blockchains 227 Novi 228 How the Libra Protocol Works 228 Summary 230 10. The Future of Blockchain. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 The More Things Change 232 Blockchains to Watch 233 How Monero Works 234 Mimblewimble, Beam, and Grin 237 The Scaling Problem 237 Sidechains 238 Sharding 238 STARKs 238 DAGs 238 Avalanche 239 Liquid 239 Lightning 239 Ethereum Scaling 245 Privacy 246 Interoperability 247 Tokenize Everything 247 Summary 247 Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 Table of Contents | xi
📄 Page 14
(This page has no text content)
📄 Page 15
Preface The goal of this book is to educate on all areas of the blockchain, using facts and data rather than bias or promotion. As authors we’ve researched using multiple data sour‐ ces, and we’ve interviewed dozens of experts in the field to provide a more holistic and accurate view of what is really happening in the blockchain industry. Conventions Used in This Book The following typographical conventions are used in this book: Italic Indicates new terms, URLs, email addresses, filenames, and file extensions. Constant width Used for program listings, as well as within paragraphs to refer to program ele‐ ments such as variable or function names, databases, data types, environment variables, statements, and keywords. Constant width bold Highlights important elements in program listings. This element signifies a tip or suggestion. This element signifies a general note. xiii
📄 Page 16
Using Code Examples Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/Mastering-Blockchain-Book. If you have a technical question or a problem using the code examples, please send email to bookquestions@oreilly.com. This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require per‐ mission. We appreciate, but generally do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Mastering Blockchain by Lorne Lantz and Daniel Cawrey (O’Reilly). Copyright 2021 Lorne Lantz and Daniel Cawrey, 978-1-492-05470-2.” If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at permissions@oreilly.com. O’Reilly Online Learning For more than 40 years, O’Reilly Media has provided technol‐ ogy and business training, knowledge, and insight to help companies succeed. Our unique network of experts and innovators share their knowledge and expertise through books, articles, and our online learning platform. O’Reilly’s online learning platform gives you on-demand access to live training courses, in-depth learning paths, interactive coding environments, and a vast collection of text and video from O’Reilly and 200+ other publishers. For more information, visit http://oreilly.com. xiv | Preface
📄 Page 17
How to Contact Us Please address comments and questions concerning this book to the publisher: O’Reilly Media, Inc. 1005 Gravenstein Highway North Sebastopol, CA 95472 800-998-9938 (in the United States or Canada) 707-829-0515 (international or local) 707-829-0104 (fax) We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at https://oreil.ly/mastering-blockchain. Email bookquestions@oreilly.com to comment or ask technical questions about this book. For news and information about our books and courses, visit http://oreilly.com. Find us on Facebook: http://facebook.com/oreilly Follow us on Twitter: http://twitter.com/oreillymedia Watch us on YouTube: http://youtube.com/oreillymedia Acknowledgments Thanks to J.R. Willett, Preston Byrne, Joey Krug, Tom Menner, Daniel Feichtinger, Addison Cameron-Huff, Scott Robinson, Elliott Williams, Neal Reiter, Moe Adham, Alex Waters, Charlie Lee, Francisco Giordano, Casey Detrio, Ben Chan, Paul Brody, Tim Swanson, Jake Brukhman, Kevin Owocki, Witek Radomski, Michael Weiksner, Taariq Lewis, Gareth MacLeod, John Wolpert, Jeff Flowers, Karen Kilroy, Gavin Low Zhe Bang, Aaron Caswell, Jorge Lesmes, Colin Goltra, Reuben Bramanathan, Dee Goens, and Kara Miley. Preface | xv
📄 Page 18
(This page has no text content)
📄 Page 19
CHAPTER 1 Origins of Blockchain Technology The term blockchain may sound mysterious or even scary to the uninitiated. Its literal meaning—a chain of blocks of information—is perhaps the simplest way to explain blockchain. But what is it for? Why does anyone need something called a blockchain? To find the answer we need to look back to an earlier time, closer to the start of the web. The internet is about storage and distribution of information to large numbers of people. Blockchain has a similar goal, and it builds on previous experiments look‐ ing for ways to improve that distribution. Electronic Systems and Trust Before blockchain, cryptocurrency, or the systems that use them, could ever be a real‐ ity, the internet needed to exist in a reliable and distributed manner, and it needed to be used by a lot of people. In its infancy in the 1960s, the internet was a simple, rela‐ tively small network, and it was primarily used as a tool for university researchers and the US government to share information digitally. Over time, early internet pioneers made the system more usable. The biggest impacts came from the development of TCP/IP, which established a standard for communica‐ tion, HTTP, which enabled web browsing, and SMTP, which delivered electronic mail. These protocols made the internet accessible not just to researchers, but to everyone, and on a growing number of devices, including computers and later tablets and smartphones. The evolution of the internet has changed life forever—incredibly large amounts of information and services are now available in the palm of anyone’s hand, much of it for free. However, using most online products or services requires a person or entity, known as a third party, to act as a trusted gatekeeper. These systems require two types of trust: 1
📄 Page 20
Intermediary trust A third party is relied on to make rational and fair decisions. Issuance trust A third party is relied on to ensure the safety and security of any value. Financial transactions are one major area where this trust is relied upon, since most money has become digital. For various reasons, the use of fiat paper money, or government-issued physical cash, is on the decline—people today utilize electronic financial tools like debit and credit cards more than ever before. In some countries, such as Sweden, payment systems are almost entirely electronic, with most customers using smartphones and cards at the point of sale. But while for consumers the shift of payment interfaces from physical to digital is a relatively recent trend, the systems powering this accounting have long been electronic. Although cash is still readily available to most, money has largely gone from paper and coins to just numbers in a computer system, without many people even noticing. When value is moved from physical items to a database, there must be an element of trust among the multiple parties involved. Huge payment companies around the world have been created based on the idea that people storing value digitally can trust these brands. However, trust hasn’t always been a reliable factor in finance. In fact, the 2008 financial crisis gave people pause, and many began to think that perhaps blind trust and faith in financial institutions wasn’t what it cracked up to be. Blockchain is an effort to reestablish lost trust. It uses technology— specifically cryptography—to automate and enforce trust in a third party. Bitcoin was the first working system to use a blockchain. But before Bitcoin came into existence, several predecessors tried—and failed—to create similar concepts. One of the main reasons they failed was the inability to put together a truly dis‐ tributed system on the internet. Distributed Versus Centralized Versus Decentralized The internet today is a mix of centralized and distributed applications, though it was designed as a distributed technology. Rather than building a centralized structure with one point of failure, early internet architects wanted to create a more resilient system. The idea for a distributed internet came from the goal (inspired by the mili‐ tary) of ensuring that if one part of the system were attacked, it would still be able to operate if properly distributed. 2 | Chapter 1: Origins of Blockchain Technology
The above is a preview of the first 20 pages. Register to read the complete e-book.

💝 Support Author

0.00
Total Amount (¥)
0
Donation Count

Login to support the author

Login Now
Back to List