timezone |
---|
Asia/Shanghai |
-
自我介绍
2021 接触 Solidity,从合约到全端完成了 3 个 NFT 项目,ex-Tech lead 链游
-
你认为你会完成本次残酷学习吗?
必须的
Solidity
is a programming language for Smart Contract development on EVM (Ethereum Virtual Machine).Remix
is a browser-based IDE (Integrated Development Environment) for Solidity development, it have file management, compiler, deployment, interaction and various plugins available.- A Solidity Smart Contract consists of 3 parts: License type, Solidity version and contract logics.
-
3 types of Variable: Value, Reference and Mapping
-
Value types:
bool
Booleanuint
Unsigned integerint
Signed integeraddress
Addressbytes
Variable-length bytes arraysbyte
Fixed-length byt arraysenum
Enumeration
Format of a function
function <function name>(<parameter types>) [public|private|external|internal] [pure|view|payable] [returns (<return types>)]
-
Function visibility specifiers
public
: Accessible to allprivate
: Can only be called within this contractinternal
: Can be called within this contract and contracts deriving from itexternal
: Can only be called by external
-
Function behavior specifiers
pure
: Cannot read or write stateview
: Read only, doesn't change statepayable
: Allow contract to receive native currency
function testReturn() public pure returns (uint256) {
return 1;
}
returns
used to indicate how many and what type of variable for outputreturn
used to output the desired value, and must matched to thereturns
requirements- Named returns: Naming the output variables, eg:
function testReturn() public pure returns (uint256 one, uint256 two) { one = 1; two = 2; }
- To read variables return from function
or
(uint256 one, uint256 two) = testReturn();
(, uint256 two) = testReturn();