Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some wordings #756

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions 02_ValueTypes/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ bool public _bool5 = _bool != _bool1; // 不相等
```solidity
// 整型
int public _int = -1; // 整数,包括负数
uint public _uint = 1; // 正整数
uint256 public _number = 20220330; // 256位正整数
uint public _uint = 1; // 无符号整数
uint256 public _number = 20220330; // 256位无符号整数
```

常用的整型运算符包括:

- 比较运算符(返回布尔值): `<=`, `<`,`==`, `!=`, `>=`, `>`
- 算数运算符: `+`, `-`, `*`, `/`, `%`(取余),`**`(幂)
- 算术运算符: `+`, `-`, `*`, `/`, `%`(取余),`**`(幂)

```solidity
// 整数运算
Expand Down Expand Up @@ -117,7 +117,7 @@ bytes32 public _byte32 = "MiniSolidity";
bytes1 public _byte = _byte32[0];
```

在上述代码中,`MiniSolidity` 变量以字节的方式存储进变量 `_byte32`。如果把它转换成 `16 进制`,就是:`0x4d696e69536f6c69646974790000000000000000000000000000000000000000`
在上述代码中,字符串 `MiniSolidity` 以字节的方式存储进变量 `_byte32`。如果把它转换成 `16 进制`,就是:`0x4d696e69536f6c69646974790000000000000000000000000000000000000000`

`_byte` 变量的值为 `_byte32` 的第一个字节,即 `0x4d`。

Expand All @@ -132,7 +132,7 @@ enum ActionSet { Buy, Hold, Sell }
ActionSet action = ActionSet.Buy;
```

枚举可以显式地和 `uint` 相互转换,并会检查转换的正整数是否在枚举的长度内,否则会报错:
枚举可以显式地和 `uint` 相互转换,并会检查转换的无符号整数是否在枚举的长度内,否则会报错:

```solidity
// enum可以和uint显式的转换
Expand All @@ -141,7 +141,7 @@ function enumToUint() external view returns(uint){
}
```

`enum` 是一个比较冷门的变量,几乎没什么人用。
`enum` 是一个比较冷门的数据类型,几乎没什么人用。

## 在 Remix 上运行

Expand Down
2 changes: 1 addition & 1 deletion 05_DataStorage/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function global() external view returns(address, uint, bytes memory){

在上面例子里,我们使用了3个常用的全局变量:`msg.sender`,`block.number`和`msg.data`,他们分别代表请求发起地址,当前区块高度,和请求数据。下面是一些常用的全局变量,更完整的列表请看这个[链接](https://learnblockchain.cn/docs/solidity/units-and-global-variables.html#special-variables-and-functions):

- `blockhash(uint blockNumber)`: (`bytes32`) 给定区块的哈希值 – 只适用于256最近区块, 不包含当前区块。
- `blockhash(uint blockNumber)`: (`bytes32`) 给定区块的哈希值 – 只适用于最近的256个区块, 不包含当前区块。
- `block.coinbase`: (`address payable`) 当前区块矿工的地址
- `block.gaslimit`: (`uint`) 当前区块的gaslimit
- `block.number`: (`uint`) 当前区块的number
Expand Down
2 changes: 1 addition & 1 deletion 10_InsertionSort/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Remix decoded output 出现错误内容

### 正确的Solidity插入排序

花了几个小时,在`Dapp-Learning`社群一个朋友的帮助下,终于找到了`bug`所在。`Solidity`中最常用的变量类型是`uint`,也就是正整数,取到负值的话,会报`underflow`错误。而在插入算法中,变量`j`有可能会取到`-1`,引起报错。
花了几个小时,在`Dapp-Learning`社群一个朋友的帮助下,终于找到了`bug`所在。`Solidity`中最常用的变量类型是`uint`,也就是无符号整数,取到负值的话,会报`underflow`错误。而在插入算法中,变量`j`有可能会取到`-1`,引起报错。

这里,我们需要把`j`加1,让它无法取到负值。正确代码:

Expand Down
2 changes: 1 addition & 1 deletion 13_Inheritance/Inheritance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.21;
contract Yeye {
event Log(string msg);

// 定义3个function: hip(), pop(), man(),Log值为Yeye。
// 定义3个function: hip(), pop(), yeye(),Log值为Yeye。
function hip() public virtual{
emit Log("Yeye");
}
Expand Down
2 changes: 1 addition & 1 deletion 13_Inheritance/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mapping(address => uint256) public override balanceOf;
contract Yeye {
event Log(string msg);

// 定义3个function: hip(), pop(), man(),Log值为Yeye。
// 定义3个function: hip(), pop(), yeye(),Log值为Yeye。
function hip() public virtual{
emit Log("Yeye");
}
Expand Down
4 changes: 2 additions & 2 deletions 17_Library/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ tags:
3. 不能接收以太币
4. 不可以被销毁

需要注意的是,库合约重的函数可见性如果被设置为`public`或者`external`,则在调用函数时会触发一次`delegatecall`。而如果被设置为`internal`,则不会引起。对于设置为`private`可见性的函数来说,其仅能在库合约中可见,在其他合约中不可用。
需要注意的是,库合约中的函数可见性如果被设置为`public`或者`external`,则在调用函数时会触发一次`delegatecall`。而如果被设置为`internal`,则不会引起。对于设置为`private`可见性的函数来说,其仅能在库合约中可见,在其他合约中不可用。


## Strings库合约
Expand Down Expand Up @@ -103,7 +103,7 @@ library Strings {
}
```

他主要包含两个函数,`toString()`将`uint256`转为`string`,`toHexString()`将`uint256`转换为`16进制`,在转换为`string`。
它主要包含两个函数,`toString()`将`uint256`转换为10进制的`string`,`toHexString()`将`uint256`转换为16进制的`string`。

### 如何使用库合约

Expand Down
8 changes: 4 additions & 4 deletions Languages/en/02_ValueTypes_en/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ Integers types in Solidity include signed integer `int` and unsigned integer `ui

```solidity
// Integer
int public _int = -1; // integers including negative numbers
uint public _uint = 1; // non-negative numbers
uint256 public _number = 20220330; // 256-bit positive integers
int public _int = -1; // integers including negative integers
uint public _uint = 1; // unsigned integers
uint256 public _number = 20220330; // 256-bit unsigned integers
```
Commonly used integer operators include:

Expand All @@ -79,7 +79,7 @@ Code:
uint256 public _number1 = _number + 1; // +, -, *, /
uint256 public _number2 = 2**2; // Exponent
uint256 public _number3 = 7 % 2; // Modulo (Modulus)
bool public _numberbool = _number2 > _number3; // Great than
bool public _numberbool = _number2 > _number3; // Greater than
```

You can run the above code and check the values of each variable.
Expand Down