Book Image

Learn Ethereum

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

Learn Ethereum

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

Overview of this book

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.
Table of Contents (19 chapters)
Free Chapter
1
Section 1: Blockchain and Ethereum Basics
5
Section 2: Blockchain Development Cycle
8
Section 3: Ethereum Implementations
12
Section 4: Production and Deployment
16
Section 5: Conclusion

Learning the fundamental programming structure in Solidity

Let's get a taste of Solidity's code and use an example to show you the layout and constructs of a smart contract. We will begin with the most basic smart contract example, HelloWorld.sol, as shown in the following screenshot:

Solidity's file extension is .sol. It is similar to .js for JavaScript files and .java for Java source code. The preceding code defines a smart contract called HelloWorld, which has has a contractor for setting the initial greeting, defines a setGreeting method to reset the greeting, and a hello method for the authorized party to get the greeting. In the rest of this section, we will go over the fundamentals of the Solidity programming language, including the following:

  • The layout of a Solidity source file
  • Structure of a contract
  • State variables
  • Functions
  • Function modifiers

...