Klaytn Docs
Search…
KlaytnGreeter
KlaytnGreeter is a simple contract that returns a greeting message. Greeting message is set when the contract is deployed.

Writing KlaytnGreeter

1
pragma solidity 0.5.6;
2
contract Mortal {
3
/* Define variable owner of the type address */
4
address payable owner;
5
/* This function is executed at initialization and sets the owner of the contract */
6
constructor () public { owner = msg.sender; }
7
/* Function to recover the funds on the contract */
8
function kill() public { if (msg.sender == owner) selfdestruct(owner); }
9
}
10
11
contract KlaytnGreeter is Mortal {
12
/* Define variable greeting of the type string */
13
string greeting;
14
/* This runs once when the contract is created */
15
constructor (string memory _greeting) public {
16
greeting = _greeting;
17
}
18
/* Main function */
19
function greet() public view returns (string memory) {
20
return greeting;
21
}
22
}
Copied!

Deploying KlaytnGreeter using Klaytn IDE

References

For the details of contract deployment and the Klaytn IDE usage guideline, please refer to the following documents.
Last modified 10d ago