Skip to content

Commit 1ba0c9f

Browse files
author
ci-bot
committed
add_tutorials
1 parent 2a24ceb commit 1ba0c9f

File tree

645 files changed

+22579
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

645 files changed

+22579
-0
lines changed

01_HelloWeb3_en/config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
id: '01'
2+
name: 1. HelloWeb3 (Solidity in 3 lines)
3+
summary: '`Solidity` is a programming language used for creating smart contracts on
4+
the Ethereum Virtual Machine (EVM). It''s a necessary skill for working on blockchain
5+
projects. Moreover, as many of them are o'
6+
level: beginner
7+
tags:
8+
- solidity
9+
- tutorial
10+
steps:
11+
- name: HelloWeb3 (Solidity in 3 lines)
12+
path: step1

01_HelloWeb3_en/readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# WTF Solidity Tutorial: 1. HelloWeb3 (Solidity in 3 lines)
2+
3+
4+
---
5+
6+
**[Continue to full tutorial →](./step1/step1.md)**
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.21;
3+
contract HelloWeb3{
4+
string public _string = "Hello Web3!";}
5+

01_HelloWeb3_en/step1/img/1-1.png

27.5 KB
Loading

01_HelloWeb3_en/step1/img/1-2.png

80.1 KB
Loading

01_HelloWeb3_en/step1/img/1-3.png

68.3 KB
Loading

01_HelloWeb3_en/step1/step1.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# WTF Solidity Tutorial: 1. HelloWeb3 (Solidity in 3 lines)
2+
3+
Recently, I have been revisiting Solidity, consolidating the finer details, and writing "WTF Solidity" tutorials for newbies.
4+
5+
Twitter: [@0xAA_Science](https://twitter.com/0xAA_Science) | [@WTFAcademy_](https://twitter.com/WTFAcademy_)
6+
7+
Community: [Discord](https://discord.gg/5akcruXrsk)[Wechat](https://docs.google.com/forms/d/e/1FAIpQLSe4KGT8Sh6sJ7hedQRuIYirOoZK_85miz3dw7vA1-YjodgJ-A/viewform?usp=sf_link)[Website wtf.academy](https://wtf.academy)
8+
9+
Codes and tutorials are open source on GitHub: [github.com/AmazingAng/WTF-Solidity](https://github.com/AmazingAng/WTF-Solidity)
10+
11+
-----
12+
13+
## WTF is Solidity?
14+
15+
`Solidity` is a programming language used for creating smart contracts on the Ethereum Virtual Machine (EVM). It's a necessary skill for working on blockchain projects. Moreover, as many of them are open-source, understanding the code can help in avoiding money-losing projects.
16+
17+
18+
`Solidity` has two characteristics:
19+
20+
1. Object-oriented: After learning it, you can use it to make money by finding the right projects.
21+
2. Advanced: If you can write smart contracts in Solidity, you are the first class citizen of Ethereum.
22+
23+
## Development tool: Remix
24+
25+
In this tutorial, we will be using `Remix` to run `solidity` contracts. `Remix` is a smart contract development IDE (Integrated Development Environment) recommended by Ethereum official. It is suitable for beginners, allows for quick deployment and testing of smart contracts in the browser, without needing to install any programs on your local machine.
26+
27+
Website: [remix.ethereum.org](https://remix.ethereum.org)
28+
29+
Upon entering `Remix`, you can see that the menu on the left-hand side has three buttons, corresponding to the file (where you write the code), compile (where you run the code), and deploy (where you deploy to the chain). By clicking the "Create New File" button, you can create a blank `solidity` contract.
30+
31+
Within Remix, we can see that there are four buttons on the leftmost vertical menu, corresponding to FILE EXPLORER (where to write code), SEARCH IN FILES (find and replace files), SOLIDITY COMPILER (to run code), and DEPLOY & RUN TRANSACTIONS (on-chain deployment). We can create a blank Solidity contract by clicking the `Create New File` button.
32+
33+
![Remix Menu](./img/1-1.png)
34+
35+
## The first Solidity program
36+
37+
This one is easy, the program only contains 1 line of comment and 3 lines of code:
38+
39+
```solidity
40+
// SPDX-License-Identifier: MIT
41+
pragma solidity ^0.8.21;
42+
contract HelloWeb3{
43+
string public _string = "Hello Web3!";}
44+
```
45+
46+
Now, we will breakdown and analyze the source code in detail, understanding the basic structure:
47+
48+
1. The first line is a comment, which denotes the software license (license identifier) used by the program. We are using the MIT license. If you do not indicate the license used, the program can compile successfully but will report a warning during compilation. Solidity's comments are denoted with "//", followed by the content of the comment (which will not be run by the program).
49+
50+
```solidity
51+
// SPDX-License-Identifier: MIT
52+
```
53+
54+
2. The second line declares the Solidity version used by the source file because the syntax of different versions is different. This line of code means that the source file will not allow compilation by compiler versions lower than v0.8.21 and not higher than v0.9.0 (the second condition is provided by `^`).
55+
56+
```solidity
57+
pragma solidity ^0.8.21;
58+
```
59+
60+
3. Lines 3 and 4 are the main body of the smart contract. Line 3 creates a contract with the name `HelloWeb3`. Line 4 is the content of the contract. Here, we created a string variable called `_string` and assigned "Hello Web3!" as value to it.
61+
62+
```solidity
63+
contract HelloWeb3{
64+
string public _string = "Hello Web3!";}
65+
```
66+
We will introduce the different variables in Solidity later.
67+
68+
## Code compilation and deployment
69+
70+
In the code editor, press CTRL+S to compile the code.
71+
72+
After compilation, click the `Deploy` button on the left menu to enter the deployment page.
73+
74+
![](./img/1-2.png)
75+
76+
By default, Remix uses the JavaScript virtual machine to simulate the Ethereum chain and run smart contracts, similar to running a testnet on the browser. Remix will allocate several test accounts to you, each with 100 ETH (test tokens). You can click `Deploy` (yellow button) to deploy the contract.
77+
78+
![](./img/1-3.png)
79+
80+
After a successful deployment, you will see a contract named `HelloWeb3` below. By clicking on the variable `_string`, it will print its value: `"Hello Web3!"`.
81+
82+
## Summary
83+
84+
In this tutorial, we briefly introduced `Solidity`, `Remix` IDE, and completed our first Solidity program - `HelloWeb3`. Going forward, we will continue our Solidity journey.
85+
86+
### Recommended materials on Solidity:
87+
88+
1. [Solidity Documentation](https://docs.soliditylang.org/en/latest/)
89+
2. [Solidity Tutorial by freeCodeCamp](https://www.youtube.com/watch?v=ipwxYa-F1uY)

02_ValueTypes_en/config.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
id: '02'
2+
name: 2. Value Types
3+
summary: 1. **Value Type**:This includes boolean, integer, etc. These variables directly
4+
pass values when assigned.
5+
level: beginner
6+
tags:
7+
- solidity
8+
- tutorial
9+
steps:
10+
- name: Value Types
11+
path: step1

02_ValueTypes_en/readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# WTF Solidity Tutorial: 2. Value Types
2+
3+
4+
---
5+
6+
**[Continue to full tutorial →](./step1/step1.md)**
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.21;
3+
contract ValueTypes{
4+
// Boolean
5+
bool public _bool = true;
6+
// Boolean operators
7+
bool public _bool1 = !_bool; // logical NOT
8+
bool public _bool2 = _bool && _bool1; // logical AND
9+
bool public _bool3 = _bool || _bool1; // logical OR
10+
bool public _bool4 = _bool == _bool1; // equality
11+
bool public _bool5 = _bool != _bool1; // inequality
12+
13+
14+
// Integer
15+
int public _int = -1;
16+
uint public _uint = 1;
17+
uint256 public _number = 20220330;
18+
// Integer operators
19+
uint256 public _number1 = _number + 1; // +,-,*,/
20+
uint256 public _number2 = 2**2; // exponent
21+
uint256 public _number3 = 7 % 2; // modulo (modulus)
22+
bool public _numberbool = _number2 > _number3; // greater than
23+
24+
25+
// Address data type
26+
address public _address = 0x7A58c0Be72BE218B41C608b7Fe7C5bB630736C71;
27+
address payable public _address1 = payable(_address); // payable address (allows for token transfer and balance checking)
28+
// Members of addresses
29+
uint256 public balance = _address1.balance; // balance of address
30+
31+
32+
// Fixed-size byte arrays
33+
bytes32 public _byte32 = "MiniSolidity"; // bytes32: 0x4d696e69536f6c69646974790000000000000000000000000000000000000000
34+
bytes1 public _byte = _byte32[0]; // bytes1: 0x4d
35+
36+
37+
// Enumeration
38+
// Let uint 0, 1, 2 represent Buy, Hold, Sell
39+
enum ActionSet { Buy, Hold, Sell }
40+
// Create an enum variable called action
41+
ActionSet action = ActionSet.Buy;
42+
43+
// Enum can be converted into uint
44+
function enumToUint() external view returns(uint){
45+
return uint(action);
46+
}
47+
}
48+

0 commit comments

Comments
 (0)