Welcome to the Ethereum-Smart-Contract-Guide! This guide is designed to teach you master the basic and complete process of smart contract development (writing, deploying, testing, and calling contracts).
This tutorial does not aim for comprehensive knowledge, but follows Elon Musk's learning method: building a knowledge syntax tree.
A bit of advice:
It's important to view knowledge as a semantic tree - make sure you understand the fundamental principles,
i.e. the trunk and big branches, before you get into the leaves/details or there is nothing for them to hang on to.
Therefore, this tutorial will focus on core concepts, and we believe that after completing the study, you will have the ability to explore more details independently.
- Tutorial Introduction
- Ethereum Development Overview
- Getting Started with Ethereum Development
- Advanced Ethereum
- Summary
By developing a practical TODO application, we will gradually delve into various aspects of Ethereum contract development. Starting from the basics and progressing to more complex topics, we ensure that you can firmly grasp the content learned at each step.
Solidity is the official language of Ethereum, unlike Solana which can use multiple languages such as Rust, C++, etc.
Although Vyper can also be used for Ethereum application development, it is not recommended due to security issues (such as the Vyper reentrancy vulnerability).
If you have experience with any programming language, learning Solidity will be relatively easy. Solidity can be understood as a simplified version of high-level languages, for example: Solidity ≈ Java - multithreading.
Hardhat is a powerful auxiliary tool that provides compilation, testing, and deployment functions, allowing developers to focus on contract development and verification.
Similar tools include the official Remix, open-source Forge, Truffle, etc. This tutorial chooses Hardhat, mastering one is sufficient, there's no need to pursue comprehensiveness.
After deploying a contract, RPC is needed when calling contract methods or querying data.
RPC is simple to use, just provide a URL, and Hardhat can handle all related operations for us through that URL. We won't delve into specific functions (such as eth_sendRawTransaction
) for now, focusing on the current learning priorities.
This section begins to involve code writing. It's recommended to practice hands-on, as practice is the best learning method.
We will gradually understand Ethereum contract development by developing a TODO application. After completing this chapter, you will master the basic knowledge of contract development.
Learning content in this subsection: Basic contract structure
Learning content in this subsection: Structs, data structures, functions
Learning content in this subsection: Memory/Storage keywords
Learning content in this subsection: View functions
Learning content in this subsection: Use of Events
Learning content in this subsection: Writing and running contract test code using Hardhat.
The importance of contract testing: You're dealing with real money. And once a contract is deployed, it cannot be modified, leaving you helpless if problems are discovered after going live.
Thorough testing is crucial, and unit tests need to be written. Fortunately, this process is relatively simple.
Learning content in this subsection: Deploying contracts using Hardhat
Learning content in this subsection: Interacting with contracts using Hardhat
Simply put: Security > Performance > Others.
On-chain security involves multiple aspects, including reentrancy attacks, integer overflow, access control, etc. Various security risks need to be carefully considered during development. Some real security incidents that have occurred will be showcased here.