1.首先我們要進入 remix 開始編輯
2.開始建立我們第一個 SmatContract
contracts → New File → 1_SaySomeThing.sol
輸入程式碼:
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
contract SaySomeThing {
string strValue;
event ValueChanged(string newValue);
function say(string memory newThing) public {
strValue = newThing;
emit ValueChanged(newThing);
}
function retrieve() public view returns (string memory) {
return strValue;
}
}
編譯
Compile → 出現打勾 (這樣才算正確)
Deploy
5.結果
執行測試
展開 Deployed Contracts 可以看到剛剛寫的兩個 function
首先我們點擊 retrieve
Say → Hello World ,retreve → 呈現 Hello World,可以看到每個動作其實都會記錄下來。
下面開始對於此合約展開一些基本知識。
有任何問題可反饋: [email protected]