跳至主要内容
本页面使用机器翻译自英语,可能包含错误或不清楚的语言。如需最准确的信息,请参阅英文原文。由于更新频繁,部分内容可能与英文原文有出入。请加入我们在 Crowdin 上的努力,帮助我们改进本页面的翻译。 (Crowdin translation page, Contributing guide)

KaiaGreeter

KaiaGreeter is a simple contract that returns a greeting message. Greeting message is set when the contract is deployed.

Writing KaiaGreeter


// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract KaiaGreeter {
/* Define variable greeting of the type string */
string greeting;
/* This runs once when the contract is created */
constructor (string memory _greeting) {
greeting = _greeting;
}
/* Main function */
function greet() public view returns (string memory) {
return greeting;
}
}

Deploying KaiaGreeter using Remix Online IDE

  • Please visit Kaia Plugin for Remix and create a KaiaGreeter.sol contract.

  • Copy and paste the code above in your newly created file: KaiaGreeter.sol.

  • Get some test KAIA from the faucet if you don’t already have test KAIA.

  • Deploy the contract with initial parameter, a greeting message.

  • After deploying, you can invoke greet from the IDE.

References

For the details of contract deployment and the Remix Online IDE usage guideline, please refer to the following documents.

让这个页面变得更好