timezone |
---|
Asia/Taipei |
- 自我介绍
大家好我是Robin(cxk228922),一名正在台灣就讀高二的學生,對資訊安全頗有興趣
之前都是往計算機本身漏洞探究,想慢慢跨進到網路相關的內容。 - 你认为你会完成本次残酷学习吗?
我會盡我所能完成一切
這邊先和助教說聲抱歉,由於我最近課業繁忙,並且對網路、區塊鏈並沒有基礎,每天能學習的內容有限><。以及我想趁此機會練習英文,文法可能有許多不妥處,可能有點難以閱讀。
- Remix IDE
- File Extension of Solidity :
.sol
Ctrl
+S
-> CompileDeploy
-> Simulate Ethereum chain -> run smart contracts
- Basic
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;
contract HelloWeb3{
string public _string = "Hello Web3!";
}
// SPDX-License-Identifier: MIT
-> Denotes license identifier (MIT
for example)pragma solidity ^0.8.21;
-> Only allow compiler version0.8.21
~0.9.0
(0.8.21
for example)contract HelloWeb3
-> Similar asclass
in other programming language (HelloWeb3
for example). also,we call it "合約"string public _string = "Hello Web3!";
-> Declared Variablesstring
: Value type
Type | Explain | Example |
---|---|---|
int | integer | 3 , 300 , -123 |
uint | unsigned integer(include 0) | 3 , 300 |
uint | k-bit unsigned integer | uint8 , uint64 |
bool | boolean | true , false |
address | address(e.g. ETH account) | 0x1234556 |
enum | enumeration | {Mon=1,Tue,Wed} |
public
: visibility
Type | Outside Contract | In Contract | Inheritance Contract |
---|---|---|---|
public | ✅ | ✅ | ✅ |
private | ❌ | ✅ | ❌ |
external (function) | ✅ | ✅use this.func() |
✅use this.func() |
internal | ❌ | ✅ | ✅ |
_string
: Value name,Define by your self"Hello Web3!"
: Value
function <functionName>(<Type> <ParameterName>) <visibility> <modifier> returns (<Type>)
<Type> <parameter1>
: Input parameter,e.g. int a
Also,you can input more than 1 parameter
<modifier>
:
Value | Explain |
---|---|
pure | cannot read nor write |
view | can read but cannot write |
(NULL) | can both read and write |
payable | can receive ETH |