跳至主要內容

KaiaGreeter

KaiaGreeter是一個返回問候信息的簡單合約。 問候信息在部署合同時設置。

寫作 KaiaGreeter


pragma solidity 0.5.6;
contract Mortal {
/* Define variable owner of the type address */
address payable owner;
/* This function is executed at initialization and sets the owner of the contract */
constructor () public { owner = msg.sender; }
/* Function to recover the funds on the contract */
function kill() public { if (msg.sender == owner) selfdestruct(owner); }
}
contract KaiaGreeter is Mortal {
/* Define variable greeting of the type string */
string greeting;
/* This runs once when the contract is created */
constructor (string memory _greeting) public {
greeting = _greeting;
}
/* Main function */
function greet() public view returns (string memory) {
return greeting;
}
}

使用 Remix 在線集成開發環境部署 KaiaGreeter

  • 請訪問 Kaia Plugin for Remix 並創建 "KaiaGreeter "合同。 上文提供了完整的源代碼。
  • 準備用於部署合同的賬戶。
    • 如果您還沒有帳號,請使用 Kaia Toolkit 建立一個帳號。
    • 從龍頭取得一些測試 KAIA - 龍頭
  • 部署帶有初始參數(問候語)的合同。
  • 部署完成後,可以在集成開發環境中調用 greet

參考資料

有關合同部署詳情和 Remix Online IDE 使用指南,請參閱以下文件。

讓這個頁面變得更好