Book Image

Learn Ethereum - Second Edition

By : Xun (Brian) Wu, Zhihong Zou, Dongying Song
Book Image

Learn Ethereum - Second Edition

By: Xun (Brian) Wu, Zhihong Zou, Dongying Song

Overview of this book

Ethereum is a blockchain-based, decentralized computing platform that allows you to run smart contracts. With this book, you’ll discover the latest Ethereum tools, frameworks, wallets, and layer 2, along with setting up and running decentralized applications for the complete, end-to-end development experience. Learn Ethereum, 2nd Edition is a comprehensive overview of the Ethereum ecosystem, exploring its concepts, mechanisms, and decentralized application development process. You’ll delve into Ethereum's internals, technologies, and tools, including Ethereum 2.0 and the Ethereum Virtual Machine (EVM), gas, and its account systems. You’ll also explore Ethereum's transition to proof of stake, L1/L2 scaling solutions, DeFi protocols, and the current marketplace. Additionally, you’ll learn about EVM-compatible blockchains, connectivity techniques, and advanced topics such as sharding, off-chain scaling, DAOs, Metaverse, and NFTs. By the end of this book, you’ll be well-equipped to write smart contracts and develop, test, and deploy DApps using various tools, wallets, and frameworks.
Table of Contents (24 chapters)
1
Part 1: Blockchain and Ethereum Basics
7
Part 2:Ethereum Development Fundamentals
11
Part 3: Ethereum Development Fundamentals
15
Part 4:Production and Deployment
20
Part 5:Conclusion

What this book covers

Chapter 1, Blockchain and Cryptocurrency, covers a comprehensive understanding of blockchain technologies, specifically focusing on the Ethereum ecosystem. Starting with basic concepts relating to Bitcoin, Ethereum, cryptocurrency, and blockchain, the book covers topics such as introducing blockchain technology, exploring cryptography, understanding the blockchain consensus mechanism, delving into Bitcoin and cryptocurrency, previewing blockchain use cases in various industries and government sectors, and introducing the world of Ethereum. By the end of this chapter, you will have gained the necessary knowledge to understand Ethereum accounts, forks, and the concept of mining.

Chapter 2, Ethereum Architecture and Ecosystem, describes the architecture of Ethereum and helps you understand EVM, gas, and accounts, among other concepts. It also covers the fundamentals of ether mining. The chapter delves into how the Beacon Chain operates and how Ethereum implements the PoS consensus mechanism. Additionally, it explores Ethereum’s merge of Eth1 and Eth2. This chapter discusses the challenges of scaling Ethereum and provides an overview of various L1 and L2 scaling solutions, including optimistic rollups and ZK rollups. By the end of this chapter, you will have a solid understanding of the internals and diverse technologies within the Ethereum ecosystem.

Chapter 3, Decentralized Finance, explores cryptocurrency and DeFi. It introduces Ethereum token standards, including fungible tokens and NFTs, and delves into stablecoins, with a focus on MakerDAO.The chapter then covers various DeFi categories such as lending, borrowing, exchanges, derivatives, fund management, lotteries, payments, and insurance. Prominent protocols within each category are highlighted, providing insights into the leading players in the DeFi ecosystem. Additionally, you will gain an understanding of the current state of the DeFi marketplace. This chapter concludes by offering a forward-looking perspective on the future of DeFi. This chapter provides you with essential knowledge of Ethereum token standards, stablecoins, and the diverse range of DeFi products and services. It equips you with insights into leading protocols and a glimpse into the future of this transformative financial landscape.

Chapter 4, EVM-Compatible Blockchain Networks, offers an overview of several EVM-compatible blockchain networks, namely Binance Smart Chain, Polygon, and Avalanche. This chapter explores the functionalities and workings of each blockchain, including a detailed examination of concepts and strategies for connecting EVM-compatible chains and facilitating asset bridging across different networks. You will gain insights into the diverse ecosystem of EVM-compatible blockchains and learn about the mechanisms that enable interoperability and seamless asset transfers.

Chapter 5, Deep Research and Latest Developments in Ethereum, delves into the ongoing research and advancements within the Ethereum platform. This chapter starts by looking at challenges and considerations in distributed systems in general and introduces schools of thoughts in scaling blockchain networks. It then discusses various phases of the Ethereum roadmap post the merge. This chapter explores cutting-edge scaling solutions such as Proto-Danksharding, Danksharding, Data Availability Sampling, Maximal Extractable Value (MEV), Proposer Builder Separation (PBS), providing insights to help you make sense of the rollup-centric Ethereum roadmap. Additionally, you will gain an understanding of key improvements in user experience, including the smart contract wallet and account abstraction. This chapter also delves into the concept of zkEVM and the current state of the zkEVM implementation. This chapter provides an outlook on the future of Decentralized Autonomous Organizations (DAOs), Web3, the metaverse, NFT platforms, and blockchain technology, offering you a glimpse into the exciting possibilities and developments that lie ahead.

Chapter 6, Fundamentals of Solidity, provides a comprehensive exploration of Solidity, the leading programming language for smart contracts. You will gain a deep understanding of Solidity’s features and development tools. This chapter covers essential Solidity language fundamentals, including contract structure, patterns, and exception handling, along with smart contract security and best practices. This chapter also offers practical insights by showcasing a complete real-world smart contract developed in Solidity. You will learn how to functionally test your smart contracts and ensure their robustness. By the end of this chapter, you will have a solid foundation in Solidity and will be equipped with the knowledge and skills to build your own secure and functional smart contracts.

Chapter 7, Web3 API Fundamentals, delves into the fundamental features of the Web3 API. This chapter provides an in-depth exploration of three key Web3 APIs: web3.js for Ethereum in JavaScript, web3.py for Ethereum in Python, and web3j for Ethereum DApp development in Java. Through practical examples, you will possess the knowledge and skills of how to leverage these APIs to interact with smart contracts deployed on the blockchain.

Chapter 8, Developing Your Own Cryptocurrency, provides you with an overview of open-source smart contract libraries and delves into various ERC token standards. This chapter guides you through the process of creating your own cryptocurrencies using Solidity, starting with the ERC-20 token standard. You will learn how to develop a cryptocurrency called MyERC20Token based on the ERC-20 standard. Additionally, this chapter explores the creation of NFTs for a decentralized art marketplace, utilizing the ERC-721 standard to develop DigitalArtERC721Token. Furthermore, this chapter introduces another prominent NFT token standard, ERC1155, and provides insights into creating an ERC1155 NFT token. By the end of this chapter, you will have a comprehensive understanding of token standards, the setup of an Ethereum development environment, and the ability to create your own cryptocurrencies using various token standards.

Chapter 9, Smart Contract Development and Test Fundamentals, focuses on providing you with practical insights into using development tools and conducting tests for smart contracts. This chapter begins by demonstrating the usage of Remix, a popular web-based IDE, for smart contract development and debugging. It further explores alternative options such as the Truffle suite and Hardhat as comprehensive development frameworks. You will also gain an understanding of smart contract unit testing by applying tests to the previously developed smart contract. This chapter emphasizes the importance of testing in ensuring the functionality and security of smart contracts. By engaging with these topics, you will strengthen your proficiency in Ethereum development and be well-equipped to develop, test, and secure your own smart contracts.

Chapter 10, Writing a Frontend to Build the NFT Marketplace DApp, guides you through the process of creating a user interface (UI) for a decentralized digital art market DApp. This chapter introduces you the concept of DApps and their two-tier architecture, comprising a frontend UI layer and a smart contract backend on the blockchain. Having already learned about smart contract development and unit testing in the previous chapter, this chapter focuses on developing the UI component, which allows end users to interact with smart contracts. React, a widely used JavaScript framework, is employed for this purpose, along with the web3.js library, which facilitates communication with the Ethereum blockchain through its APIs. By following the chapter’s content, you will acquire the knowledge and skills needed to build the UI for a DApp using React and web3.js. You will gain an understanding of the essential steps involved in setting up the development environment, constructing frontend components, and ultimately running a fully functional decentralized digital art market DApp.

Chapter 11, Ethereum Tools and Frameworks, provides you with an overview of the commonly-used tools and frameworks in Ethereum development. This chapter delves into the various tools and frameworks that are typically employed in Ethereum development, including those for smart contract compilation, deployment, and testing. Additionally, it explores frameworks that facilitate the development of decentralized applications.

This chapter also covers storage options within the Ethereum ecosystem, including on-chain storage utilizing smart contracts, as well as off-chain storage using distributed file systems such as InterPlanetary File System (IPFS). You will gain an understanding of the available storage solutions and their applications. Furthermore, this chapter introduces popular smart contract libraries that offer pre-built functionalities and code templates. These libraries enable developers to streamline their development processes and enhance the security of their smart contracts.

Chapter 12, Setting Up an Ethereum Private Chain, shifts our focus to private Ethereum networks. Private blockchains are primarily used by developers for testing purposes, offering advantages such as simplified testing without the need for node syncing or obtaining test ether. This chapter guides you through the process of setting up a private blockchain using Ethereum, highlighting the differences between public and private blockchains. Additionally, it explores the application of private blockchains in production use cases.

Chapter 13, Deployment of Your DApps, focuses on the next step in the smart contract development cycle: deploying and testing contracts in an environment similar to the Ethereum main network. Testnets serve as platforms where developers can closely simulate the main network and test their contracts effectively. This chapter provides a comprehensive understanding of deploying smart contracts on popular testnets, namely the Goerli and Sepolia test networks. You will learn the step-by-step process of deploying your contracts to these testnets, enabling you to assess the functionality and behavior of your contracts in an environment that closely resembles the Ethereum main network. Furthermore, this chapter delves into monitoring smart contracts after deployment. You will gain insights into the tools and techniques used to monitor the performance and interactions of your deployed contracts. By following the content of this chapter, developers will be equipped with the knowledge and skills necessary to confidently deploy and monitor their smart contracts on testnets.

Chapter 14, Build Ethereum Wallets, provides a comprehensive overview of Ethereum wallets and guides you on how to create your own wallets. This chapter delves deeper into the technology and functionality of Ethereum wallets. You will gain a solid understanding of Ethereum wallet concepts, including non-deterministic wallets and Hierarchical Deterministic (HD) wallets. This chapter explores the features of HD wallets, which offer enhanced security and convenience through the generation of a hierarchical tree of private keys. Additionally, you will explore advanced wallet features such as multiparty signatures, stealth addresses, and confidential transactions, which provide additional layers of privacy and security. This chapter also provides step-by-step guidance on creating an Ethereum wallet, empowering you to have full control over your wallet’s security and functionality. Furthermore, you will become familiar with popular third-party Ethereum wallets, broadening your knowledge of the available wallet options and their respective features. By the end of this chapter, you will have a comprehensive understanding of Ethereum wallets, the security features they offer, and the various options available for wallet creation and management.

Chapter 15, Oracles, Cross-Chain, and Layer 2 in Practice, offers a comprehensive exploration of the fundamental concepts and technologies that enable interoperability and advanced functionalities within the decentralized Web 3.0 ecosystem. This chapter begins by providing you with a clear understanding of the crucial role played by oracles in retrieving and verifying external data, empowering smart contracts to respond and execute actions based on real-time information. Through practical examples, you will gain hands-on experience in integrating oracles into your smart contracts to access real-time token market prices.

Continuing, this chapter delves into the intricacies of cross-chain bridge technology, which facilitates seamless communication and asset transfers between different blockchain networks. By comprehending the underlying mechanics of cross-chain bridges, you will grasp their significance in enabling the smooth interoperability of tokens and data across multiple chains. Furthermore, this chapter explores L2 technologies, which effectively tackle scalability challenges by providing off-chain solutions that enhance transaction throughput and minimize fees. You will be introduced to practical implementations of L2 technologies, comprehending your potential to significantly improve the overall efficiency and user experience of DApps.

Upon concluding this chapter, you will possess a comprehensive understanding of oracles, cross-chain bridge technology, and L2 technologies. Equipped with this knowledge and the necessary tools, you will be empowered to leverage these technologies in your Ethereum projects, resulting in enhanced functionalities, seamless real-time data integration, and improved scalability.

Chapter 16, Conclusion, is a summary of the entire book and the Ethereum blockchain technologies covered therein. It offers you a comprehensive understanding of Ethereum and its blockchain technologies. It addresses the challenges, explores the ecosystem, discusses the emerging trends in the blockchain and Ethereum ecosystem, and provides a glimpse into the future of Ethereum. It serves as a valuable resource for individuals seeking to grasp the fundamental concepts, opportunities, and advancements within the Ethereum blockchain space.