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

Update Tutorials #254

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
16 changes: 16 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,19 @@ docs/ethers-101/01_HelloVitalik/HelloVitalik.js docs/ethers-101/02_Provider/Prov
Changes in docs/solidity-104:
docs/ethers-101/01_HelloVitalik/HelloVitalik.js docs/ethers-101/02_Provider/Provider.js docs/ethers-101/03_ReadContract/ReadContract.js docs/ethers-101/04_SendETH/SendETH.js docs/ethers-101/05_WriteContract/WriteContract.js docs/ethers-101/06_DeployContract/DeployContract.js docs/ethers-101/07_Event/Event.js docs/ethers-101/08_ContractListener/ContractListener.js docs/ethers-101/09_EventFilter/EventFilter.js docs/ethers-101/10_Units/Units.js docs/ethers-102/11_StaticCall/readme.md docs/ethers-102/11_StaticCall/staticCall.js docs/ethers-102/12_ERC721Check/ERC721Check.js docs/ethers-102/12_ERC721Check/readme.md docs/ethers-102/13_EncodeCalldata/EncodeCalldata.js docs/ethers-102/14_HDwallet/HDwallet.js docs/ethers-102/14_HDwallet/readme.md docs/ethers-102/15_MultiTransfer/MultiTransfer.js docs/ethers-102/15_MultiTransfer/readme.md docs/ethers-102/16_MultiCollect/MultiCollect.js docs/ethers-102/16_MultiCollect/readme.md docs/ethers-102/17_MerkleTree/MerkleTree.js docs/ethers-102/18_Signature/Signature.js docs/ethers-102/18_Signature/readme.md docs/ethers-102/19_Mempool/Mempool.js docs/ethers-102/19_Mempool/readme.md docs/ethers-102/20_DecodeTx/DecodeTx.js docs/ethers-102/20_DecodeTx/img/20-3.png docs/ethers-102/20_DecodeTx/img/20-4.png docs/ethers-102/20_DecodeTx/readme.md docs/ethers-102/21_VanityAddress/readme.md docs/ethers-102/23_Frontrun/Frontrun.sol docs/ethers-102/23_Frontrun/frontrun.js docs/ethers-102/23_Frontrun/img/23-2.png docs/ethers-102/23_Frontrun/img/23-3.png docs/ethers-102/23_Frontrun/readme.md docs/ethers-102/24_ERC20Check/readme.md docs/ethers-102/25_Flashbots/Flashbots.js docs/ethers-102/25_Flashbots/img/25-4.png docs/ethers-102/25_Flashbots/img/25-5.png docs/ethers-102/25_Flashbots/readme.md docs/solidity-101/01_HelloWeb3/HelloWeb3.sol docs/solidity-101/01_HelloWeb3/img/1-2.png docs/solidity-101/01_HelloWeb3/readme.md docs/solidity-101/02_ValueTypes/ValueTypes.sol docs/solidity-101/02_ValueTypes/readme.md docs/solidity-101/03_Function/Function.sol docs/solidity-101/03_Function/readme.md docs/solidity-101/04_Return/Return.sol docs/solidity-101/04_Return/readme.md docs/solidity-101/05_DataStorage/DataStorage.sol docs/solidity-101/05_DataStorage/readme.md docs/solidity-101/06_ArrayAndStruct/ArrayAndStruct.sol docs/solidity-101/06_ArrayAndStruct/readme.md docs/solidity-101/07_Mapping/Mapping.sol docs/solidity-101/07_Mapping/readme.md docs/solidity-101/08_InitialValue/InitialValue.sol docs/solidity-101/08_InitialValue/readme.md docs/solidity-101/09_Constant/Constant.sol docs/solidity-101/09_Constant/readme.md docs/solidity-101/10_InsertionSort/InsertionSort.sol docs/solidity-101/10_InsertionSort/readme.md docs/solidity-101/11_Modifier/Owner.sol docs/solidity-101/11_Modifier/img/11-1.jpg docs/solidity-101/11_Modifier/img/11-2.jpg docs/solidity-101/11_Modifier/img/11-3.jpg docs/solidity-101/11_Modifier/readme.md docs/solidity-101/12_Event/Event.sol docs/solidity-101/12_Event/readme.md docs/solidity-101/13_Inheritance/Inheritance.sol docs/solidity-101/13_Inheritance/ModifierInheritance.sol docs/solidity-101/13_Inheritance/readme.md docs/solidity-101/14_Interface/Interface.sol docs/solidity-101/14_Interface/img/14-2.png docs/solidity-101/14_Interface/readme.md docs/solidity-101/15_Errors/Error.sol docs/solidity-101/15_Errors/readme.md docs/solidity-102/16_Overloading/Overloading.sol docs/solidity-102/16_Overloading/readme.md docs/solidity-102/17_Library/Library.sol docs/solidity-102/17_Library/readme.md docs/solidity-102/18_Import/Yeye.sol docs/solidity-102/18_Import/readme.md docs/solidity-102/19_Fallback/Fallback.sol docs/solidity-102/19_Fallback/readme.md docs/solidity-102/20_SendETH/SendETH.sol docs/solidity-102/20_SendETH/readme.md docs/solidity-102/21_CallContract/CallContract.sol docs/solidity-102/21_CallContract/readme.md docs/solidity-102/22_Call/Call.sol docs/solidity-102/22_Call/readme.md docs/solidity-102/23_Delegatecall/Delegatecall.sol docs/solidity-102/23_Delegatecall/readme.md docs/solidity-102/24_Create/Create.sol docs/solidity-102/24_Create/readme.md docs/solidity-102/25_Create2/create2test.js docs/solidity-102/25_Create2/readme.md docs/solidity-102/26_DeleteContract/DeleteContract.sol docs/solidity-102/26_DeleteContract/img/26-1.png docs/solidity-102/26_DeleteContract/img/26-2.png docs/solidity-102/26_DeleteContract/readme.md docs/solidity-102/27_ABIEncode/ABIEncode.sol docs/solidity-102/27_ABIEncode/readme.md docs/solidity-102/28_Hash/Hash.sol docs/solidity-102/28_Hash/readme.md docs/solidity-102/29_Selector/Selector.sol docs/solidity-102/29_Selector/img/29-2.png docs/solidity-102/29_Selector/img/29-3.png docs/solidity-102/29_Selector/readme.md docs/solidity-102/30_TryCatch/TryCatch.sol docs/solidity-102/30_TryCatch/readme.md docs/solidity-103/31_ERC20/ERC20.sol docs/solidity-103/31_ERC20/IERC20.sol docs/solidity-103/31_ERC20/readme.md docs/solidity-103/32_Faucet/Faucet.sol docs/solidity-103/32_Faucet/IERC20.sol docs/solidity-103/32_Faucet/readme.md docs/solidity-103/33_Airdrop/Airdrop.sol docs/solidity-103/33_Airdrop/IERC20.sol docs/solidity-103/33_Airdrop/readme.md docs/solidity-103/34_ERC721/ERC721.sol docs/solidity-103/34_ERC721/String.sol docs/solidity-103/34_ERC721/WTFApe.sol docs/solidity-103/34_ERC721/readme.md docs/solidity-103/35_DutchAuction/DutchAuction.sol docs/solidity-103/35_DutchAuction/readme.md docs/solidity-103/36_MerkleTree/MerkleTree.sol docs/solidity-103/36_MerkleTree/readme.md docs/solidity-103/37_Signature/Signature.sol docs/solidity-103/37_Signature/readme.md docs/solidity-103/38_NFTSwap/NFTSwap.sol docs/solidity-103/38_NFTSwap/readme.md docs/solidity-103/39_Random/Random.sol docs/solidity-103/39_Random/RandomNumberConsumer.sol docs/solidity-103/39_Random/img/39-2.png docs/solidity-103/39_Random/img/39-3.png docs/solidity-103/39_Random/img/39-4.png docs/solidity-103/39_Random/img/39-5.png docs/solidity-103/39_Random/img/39-6.png docs/solidity-103/39_Random/img/39-7.png docs/solidity-103/39_Random/readme.md docs/solidity-103/40_ERC1155/BAYC1155.sol docs/solidity-103/40_ERC1155/readme.md docs/solidity-103/41_WETH/readme.md docs/solidity-103/42_PaymentSplit/PaymentSplit.sol docs/solidity-103/42_PaymentSplit/readme.md docs/solidity-103/43_TokenVesting/readme.md docs/solidity-103/44_TokenLocker/readme.md docs/solidity-103/45_Timelock/Timelock.sol docs/solidity-103/45_Timelock/readme.md docs/solidity-103/46_ProxyContract/ProxyContract.sol docs/solidity-103/46_ProxyContract/readme.md docs/solidity-103/47_Upgrade/Upgrade.sol docs/solidity-103/47_Upgrade/readme.md docs/solidity-103/48_TransparentProxy/TransparentProxy.sol docs/solidity-103/48_TransparentProxy/readme.md docs/solidity-103/49_UUPS/UUPS.sol docs/solidity-103/49_UUPS/readme.md docs/solidity-103/50_MultisigWallet/MultisigWallet.sol docs/solidity-103/50_MultisigWallet/readme.md docs/solidity-104/S01_ReentrancyAttack/ReentrancyAttack.sol docs/solidity-104/S01_ReentrancyAttack/readme.md docs/solidity-104/S02_SelectorClash/SelectorClash.sol docs/solidity-104/S02_SelectorClash/readme.md docs/solidity-104/S03_Centralization/Centralization.sol docs/solidity-104/S03_Centralization/readme.md docs/solidity-104/S04_AccessControlExploit/AccessControlExploit.sol docs/solidity-104/S04_AccessControlExploit/readme.md docs/solidity-104/S05_Overflow/Overflow.sol docs/solidity-104/S05_Overflow/readme.md docs/solidity-104/S06_SignatureReplay/SingatureReplay.sol docs/solidity-104/S06_SignatureReplay/readme.md docs/solidity-104/S07_BadRandomness/BadRandomness.sol docs/solidity-104/S07_BadRandomness/readme.md docs/solidity-104/S08_ContractCheck/ContractCheck.sol docs/solidity-104/S08_ContractCheck/readme.md docs/solidity-104/S09_DoS/DoS.sol docs/solidity-104/S09_DoS/readme.md docs/solidity-104/S10_Honeypot/Honeypot.sol docs/solidity-104/S10_Honeypot/readme.md docs/solidity-104/S11_Frontrun/Frontrun.sol docs/solidity-104/S11_Frontrun/frontrun.js docs/solidity-104/S11_Frontrun/readme.md docs/solidity-104/S12_TxOrigin/readme.md docs/solidity-104/S13_UncheckedCall/UncheckedCall.sol docs/solidity-104/S13_UncheckedCall/readme.md docs/solidity-104/S14_TimeManipulation/readme.md docs/solidity-104/S14_TimeManipulation/src/TimeManipulation.sol docs/solidity-104/S14_TimeManipulation/test/TimeManipulation.t.sol docs/solidity-104/S15_OracleManipulation/readme.md docs/solidity-104/S15_OracleManipulation/src/Oracle.sol docs/solidity-104/S15_OracleManipulation/test/Oracle.t.sol docs/solidity-104/S16_NFTReentrancy/NFTReentrancy.sol docs/solidity-104/S16_NFTReentrancy/readme.md docs/ethers-102/21_VanityAddress/BulkVanityAddress.js docs/solidity-101/05_DataStorage/img/5-5.png docs/solidity-101/05_DataStorage/img/5-6.png docs/solidity-101/06_ArrayAndStruct/img/6-4.png docs/solidity-101/06_ArrayAndStruct/img/6-5.png docs/solidity-101/11_Modifier/img/11-4.jpg docs/solidity-101/12_Event/img/12-4.png docs/solidity-101/13_Inheritance/DiamondInheritance.sol docs/solidity-101/14_Interface/AbstractDemo.sol docs/solidity-101/14_Interface/InterfaceDemo.sol docs/solidity-102/18_Import/Import.sol docs/solidity-102/25_Create2/Create2.sol docs/solidity-102/26_DeleteContract/DeployContract.sol docs/solidity-102/26_DeleteContract/img/26-3.png docs/solidity-102/26_DeleteContract/img/26-4.png docs/solidity-102/26_DeleteContract/img/26-5.png docs/solidity-102/26_DeleteContract/img/26-6.png docs/solidity-103/39_Random/img/39-10.png docs/solidity-103/39_Random/img/39-6-1.png docs/solidity-103/39_Random/img/39-8.png docs/solidity-103/39_Random/img/39-9.png docs/solidity-103/51_ERC4626/ docs/solidity-103/52_EIP712/ docs/solidity-103/53_ERC20Permit/ docs/solidity-103/54_CrossChainBridge/ docs/solidity-103/55_MultiCall/ docs/solidity-103/56_DEX/ docs/solidity-103/57_Flashloan/ docs/solidity-104/S17_CrossReentrancy/

--------------------------------
Sync started at Sun Nov 24 01:14:01 UTC 2024


Changes in docs/solidity-101:
docs/solidity-101/02_ValueTypes/readme.md docs/solidity-101/03_Function/readme.md docs/solidity-101/04_Return/readme.md docs/solidity-101/05_DataStorage/readme.md docs/solidity-101/07_Mapping/readme.md docs/solidity-101/09_Constant/readme.md docs/solidity-101/10_InsertionSort/readme.md docs/solidity-101/12_Event/readme.md docs/solidity-101/13_Inheritance/Inheritance.sol docs/solidity-101/13_Inheritance/readme.md

Changes in docs/solidity-102:
docs/solidity-101/02_ValueTypes/readme.md docs/solidity-101/03_Function/readme.md docs/solidity-101/04_Return/readme.md docs/solidity-101/05_DataStorage/readme.md docs/solidity-101/07_Mapping/readme.md docs/solidity-101/09_Constant/readme.md docs/solidity-101/10_InsertionSort/readme.md docs/solidity-101/12_Event/readme.md docs/solidity-101/13_Inheritance/Inheritance.sol docs/solidity-101/13_Inheritance/readme.md docs/solidity-102/17_Library/readme.md docs/solidity-102/23_Delegatecall/readme.md docs/solidity-102/24_Create/readme.md docs/solidity-102/26_DeleteContract/readme.md docs/solidity-102/27_ABIEncode/readme.md docs/solidity-102/30_TryCatch/readme.md docs/solidity-102/24_Create/img/24-4.png

Changes in docs/solidity-103:
docs/solidity-101/02_ValueTypes/readme.md docs/solidity-101/03_Function/readme.md docs/solidity-101/04_Return/readme.md docs/solidity-101/05_DataStorage/readme.md docs/solidity-101/07_Mapping/readme.md docs/solidity-101/09_Constant/readme.md docs/solidity-101/10_InsertionSort/readme.md docs/solidity-101/12_Event/readme.md docs/solidity-101/13_Inheritance/Inheritance.sol docs/solidity-101/13_Inheritance/readme.md docs/solidity-102/17_Library/readme.md docs/solidity-102/23_Delegatecall/readme.md docs/solidity-102/24_Create/readme.md docs/solidity-102/26_DeleteContract/readme.md docs/solidity-102/27_ABIEncode/readme.md docs/solidity-102/30_TryCatch/readme.md docs/solidity-103/34_ERC721/ERC721.sol docs/solidity-103/34_ERC721/readme.md docs/solidity-103/35_DutchAuction/readme.md docs/solidity-103/36_MerkleTree/img/36-1.png docs/solidity-103/36_MerkleTree/img/36-2.png docs/solidity-103/36_MerkleTree/readme.md docs/solidity-103/37_Signature/readme.md docs/solidity-103/38_NFTSwap/NFTSwap.sol docs/solidity-103/38_NFTSwap/readme.md docs/solidity-103/40_ERC1155/ERC1155.sol docs/solidity-103/40_ERC1155/readme.md docs/solidity-103/46_ProxyContract/readme.md docs/solidity-103/47_Upgrade/readme.md docs/solidity-103/48_TransparentProxy/readme.md docs/solidity-103/49_UUPS/readme.md docs/solidity-103/50_MultisigWallet/MultisigWallet.sol docs/solidity-103/50_MultisigWallet/readme.md docs/solidity-103/51_ERC4626/readme.md docs/solidity-103/52_EIP712/readme.md docs/solidity-103/53_ERC20Permit/readme.md docs/solidity-103/54_CrossChainBridge/crosschain.js docs/solidity-103/54_CrossChainBridge/readme.md docs/solidity-103/56_DEX/readme.md docs/solidity-102/24_Create/img/24-4.png docs/solidity-103/56_DEX/img/56-10.jpg docs/solidity-103/56_DEX/img/56-11.jpg docs/solidity-103/56_DEX/img/56-2.jpg docs/solidity-103/56_DEX/img/56-3.jpg docs/solidity-103/56_DEX/img/56-4.jpg docs/solidity-103/56_DEX/img/56-5.jpg docs/solidity-103/56_DEX/img/56-6.jpg docs/solidity-103/56_DEX/img/56-7.jpg docs/solidity-103/56_DEX/img/56-8.jpg docs/solidity-103/56_DEX/img/56-9.jpg

Changes in docs/solidity-104:
docs/solidity-101/02_ValueTypes/readme.md docs/solidity-101/03_Function/readme.md docs/solidity-101/04_Return/readme.md docs/solidity-101/05_DataStorage/readme.md docs/solidity-101/07_Mapping/readme.md docs/solidity-101/09_Constant/readme.md docs/solidity-101/10_InsertionSort/readme.md docs/solidity-101/12_Event/readme.md docs/solidity-101/13_Inheritance/Inheritance.sol docs/solidity-101/13_Inheritance/readme.md docs/solidity-102/17_Library/readme.md docs/solidity-102/23_Delegatecall/readme.md docs/solidity-102/24_Create/readme.md docs/solidity-102/26_DeleteContract/readme.md docs/solidity-102/27_ABIEncode/readme.md docs/solidity-102/30_TryCatch/readme.md docs/solidity-103/34_ERC721/ERC721.sol docs/solidity-103/34_ERC721/readme.md docs/solidity-103/35_DutchAuction/readme.md docs/solidity-103/36_MerkleTree/img/36-1.png docs/solidity-103/36_MerkleTree/img/36-2.png docs/solidity-103/36_MerkleTree/readme.md docs/solidity-103/37_Signature/readme.md docs/solidity-103/38_NFTSwap/NFTSwap.sol docs/solidity-103/38_NFTSwap/readme.md docs/solidity-103/40_ERC1155/ERC1155.sol docs/solidity-103/40_ERC1155/readme.md docs/solidity-103/46_ProxyContract/readme.md docs/solidity-103/47_Upgrade/readme.md docs/solidity-103/48_TransparentProxy/readme.md docs/solidity-103/49_UUPS/readme.md docs/solidity-103/50_MultisigWallet/MultisigWallet.sol docs/solidity-103/50_MultisigWallet/readme.md docs/solidity-103/51_ERC4626/readme.md docs/solidity-103/52_EIP712/readme.md docs/solidity-103/53_ERC20Permit/readme.md docs/solidity-103/54_CrossChainBridge/crosschain.js docs/solidity-103/54_CrossChainBridge/readme.md docs/solidity-103/56_DEX/readme.md docs/solidity-104/S01_ReentrancyAttack/readme.md docs/solidity-104/S02_SelectorClash/SelectorClash.sol docs/solidity-104/S05_Overflow/readme.md docs/solidity-104/S06_SignatureReplay/readme.md docs/solidity-104/S08_ContractCheck/readme.md docs/solidity-104/S09_DoS/readme.md docs/solidity-104/S10_Honeypot/readme.md docs/solidity-104/S13_UncheckedCall/readme.md docs/solidity-104/S15_OracleManipulation/readme.md docs/solidity-104/S15_OracleManipulation/test/Oracle.t.sol docs/solidity-102/24_Create/img/24-4.png docs/solidity-103/56_DEX/img/56-10.jpg docs/solidity-103/56_DEX/img/56-11.jpg docs/solidity-103/56_DEX/img/56-2.jpg docs/solidity-103/56_DEX/img/56-3.jpg docs/solidity-103/56_DEX/img/56-4.jpg docs/solidity-103/56_DEX/img/56-5.jpg docs/solidity-103/56_DEX/img/56-6.jpg docs/solidity-103/56_DEX/img/56-7.jpg docs/solidity-103/56_DEX/img/56-8.jpg docs/solidity-103/56_DEX/img/56-9.jpg

12 changes: 6 additions & 6 deletions docs/solidity-101/02_ValueTypes/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,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 @@ -119,7 +119,7 @@ bytes32 public _byte32 = "MiniSolidity";
bytes1 public _byte = _byte32[0];
```

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

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

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

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

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

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

## 在 Remix 上运行

Expand Down
15 changes: 11 additions & 4 deletions docs/solidity-101/03_Function/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Solidity语言的函数非常灵活,可以进行各种复杂操作。在本教
我们先看一下 Solidity 中函数的形式:

```solidity
function <function name>(<parameter types>) {internal|external|public|private} [pure|view|payable] [returns (<return types>)]
function <function name>([parameter types[, ...]]) {internal|external|public|private} [pure|view|payable] [virtual|override] [<modifiers>]
[returns (<return types>)]{ <function body> }
```

看着有一些复杂,让我们从前往后逐个解释(方括号中的是可写可不
Expand All @@ -37,7 +38,7 @@ function <function name>(<parameter types>) {internal|external|public|private} [

2. `<function name>`:函数名。

3. `(<parameter types>)`:圆括号内写入函数的参数,即输入到函数的变量类型和名称。
3. `([parameter types[, ...]])`:圆括号内写入函数的参数,即输入到函数的变量类型和名称。

4. `{internal|external|public|private}`:函数可见性说明符,共有4种。

Expand All @@ -48,11 +49,17 @@ function <function name>(<parameter types>) {internal|external|public|private} [

**注意 1**:合约中定义的函数需要明确指定可见性,它们没有默认值。

**注意 2**:`public|private|internal` 也可用于修饰状态变量。`public`变量会自动生成同名的`getter`函数,用于查询数值。未标明可见性类型的状态变量,默认为`internal`。
**注意 2**:`public|private|internal` 也可用于修饰状态变量(定义可参考[WTF Solidity 第5讲的相关内容]([../05_DataStorage/readme.md#1-状态变量](https://github.com/AmazingAng/WTF-Solidity/tree/main/05_DataStorage#1-%E7%8A%B6%E6%80%81%E5%8F%98%E9%87%8F)))。`public`变量会自动生成同名的`getter`函数,用于查询数值。未标明可见性类型的状态变量,默认为`internal`。

5. `[pure|view|payable]`:决定函数权限/功能的关键字。`payable`(可支付的)很好理解,带着它的函数,运行的时候可以给合约转入 ETH。`pure` 和 `view` 的介绍见下一节。

6. `[returns ()]`:函数返回的变量类型和名称。
6. `[virtual|override]`: 方法是否可以被重写,或者是否是重写方法。`virtual`用在父合约上,标识的方法可以被子合约重写。`override`用在自合约上,表名方法重写了父合约的方法。

7. `<modifiers>`: 自定义的修饰器,可以有0个或多个修饰器。

8. `[returns ()]`:函数返回的变量类型和名称。

9. `<function body>`: 函数体。

## 到底什么是 `Pure` 和`View`?

Expand Down
Loading