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

Understanding development using Truffle and unit testing

Truffle is a great tool that helps you to easily develop, compile, test, and deploy your smart contract in your development environment. You can use Truffle to easily set up a project and hook your frontend code with your deployed contract. In Chapter 8, Developing Your Own Cryptocurrency, we installed Truffle and briefly introduced the basic Truffle commands. In this section, we will cover Truffle development and unit testing in detail.

First, let’s take a look at the Truffle console and development features.

The Truffle console and development features

The Truffle console provides a Command-Line Interface (CLI) to connect external clients, such as Ganache and Ethereum Testnet. When you run the Truffle console under the Truffle project, it will point to the network definition under the development section in the Truffle config, as shown in the following code. The default Truffle port is 7545, and our Ganache...