KlaytnGreeter

KlaytnGreeter는 인사말 메시지를 반환하는 간단한 컨트랙트입니다. 컨트랙트가 배포될 때 인사말 메시지가 설정됩니다.

KlaytnGreeter 작성

pragma solidity 0.5.6;
contract Mortal {
    /* address 타입의 owner변수 정의 */
    address payable owner;
    /* 이 함수는 초기화 시점에 실행되어 컨트랙트 소유자를 설정합니다 */
    constructor () public { owner = msg.sender; }
    /* 컨트랙트에서 자금을 회수하는 함수 */
    function kill() public { if (msg.sender == owner) selfdestruct(owner); }
}

contract KlaytnGreeter is Mortal {
    /* string 타입의 변수 greeting 정의 */
    string greeting;
    /* 이 함수는 컨트랙트가 생성될 딱 한번 실행됩니다 */
    constructor (string memory _greeting) public {
        greeting = _greeting;
    }
    /* 주(Main) 함수 */
    function greet() public view returns (string memory) {
        return greeting;
    }
}

Deploying KlaytnGreeter using Remix Online IDE

참고

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

Last updated

Was this helpful?