아핫뉴스실시간 인기검색어
아핫뉴스 화산 이미지
화산 아이콘 11
정부, 부동산 공급 논의
아하

생활

생활꿀팁

집요한무희새195
집요한무희새195

스마트컨트랙트 해석에 관하여 문의 드립니다.

특정한 코인 트랜젝션에 관한 스마트컨트랙트의 의미가 궁금합니다.

해당 트랜젝션의 당사자는 일정기간(당사자는 1년으로 알고 있습니다) 후 자신의 전자지갑으로 해당 토큰이 지급되는 내용으로 알고 있습니다(즉, 일정기간의 락이 걸려 있는 것으로 이해하고 있습니다).

아래는 이더스캔에 보이는 해당 트랜젝션의 'Read Contract Information' 화면입니다.

스마트컨트랙트의 소스코드는 아래와 같습니다.

--------------

/**

*Submitted for verification at Etherscan.io on 2018-11-11

*/

pragma solidity ^0.4.24;

/**

* @title SafeMath

* @dev Math operations with safety checks that throw on error

*/

library SafeMath {

function mul(uint256 a, uint256 b) internal pure returns (uint256) {

uint256 c = a * b;

assert(a == 0 || c / a == b);

return c;

}

function div(uint256 a, uint256 b) internal pure returns (uint256) {

// assert(b > 0); // Solidity automatically throws when dividing by 0

uint256 c = a / b;

// assert(a == b * c + a % b); // There is no case in which this doesn't hold

return c;

}

function sub(uint256 a, uint256 b) internal pure returns (uint256) {

assert(b <= a);

return a - b;

}

function add(uint256 a, uint256 b) internal pure returns (uint256) {

uint256 c = a + b;

assert(c >= a);

return c;

}

}contract token {

function balanceOf(address _owner) public constant returns (uint256 balance);

function transfer(address to, uint256 value) public returns (bool success);

}contract Ownable {

address public owner;

event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

/**

* @dev The Ownable constructor sets the original owner of the contract to the sender

* account.

*/

constructor() public{

owner = msg.sender;

}

/**

* @dev Throws if called by any account other than the owner.

*/

modifier onlyOwner() {

require(msg.sender == owner);

_;

}

/**

* @dev Allows the current owner to transfer control of the contract to a newOwner.

* @param newOwner The address to transfer ownership to.

*/

function transferOwnership(address newOwner) onlyOwner public {

require(newOwner != address(0));

emit OwnershipTransferred(owner, newOwner);

owner = newOwner;

}

}contract LockToken is Ownable {

using SafeMath for uint256;

token token_reward;

address public beneficiary;

bool public isLocked = false;

bool public isReleased = false;

uint256 public start_time;

uint256 public end_time;

event TokenReleased(address beneficiary, uint256 token_amount);

constructor(address tokenContractAddress, address _beneficiary) public{

token_reward = token(tokenContractAddress);

beneficiary = _beneficiary;

}

function tokenBalance() constant public returns (uint256){

return token_reward.balanceOf(this);

}

function lock(uint256 lockTime) public onlyOwner returns (bool){

require(!isLocked);

require(tokenBalance() > 0);

start_time = now;

end_time = lockTime;

isLocked = true;

}

function lockOver() constant public returns (bool){

uint256 current_time = now;

return currenttime > endtime;

}

function release() onlyOwner public{

require(isLocked);

require(!isReleased);

require(lockOver());

uint256 token_amount = tokenBalance();

tokenreward.transfer( beneficiary, tokenamount);

emit TokenReleased(beneficiary, token_amount);

isReleased = true;

}

}

-----------------

위 스마트컨트랙트가 당사자가 이해하고 있는 내용이 맞는지, 트랜젝션 실행 후 어느정도의 기간이 지나면 해당 토큰을 받게 되는 것인지, 그러한 내용은 어느 부분을 보면 알 수 있는지 등이 궁금합니다.

설명이 난해할 수도 있는데 관심있게 읽어주신 점 감사드립니다.

1개의 답변이 있어요!
  • 대니월드
    대니월드

    안녕하세요 Danny입니다.

    Lock에 대한 설정은 여기에 프로그래밍 되어 있습니다.

    아래 lock 함수에서 unit256 lockTime에서 입력된 값이 lock이 종료되는 시점입니다.

    function lock(uint256 lockTime) public onlyOwner returns (bool){

    require(!isLocked);

    require(tokenBalance() > 0);

    start_time = now; / Lock 시작일

    end_time = lockTime; / Lock 종료일

    isLocked = true;

    }

    캡쳐주신 화면에 보면 아래 항목이 있는데요.

    1. end_time

    3. start_time

    여기에 Lock 시작일과 Lock종료일이 입력되어 있네요..(기안에 대한 설정은 여기에서 지정됩니다.)

    아래 부분이 토큰이 자동으로 전송되는 부분입니다.

    function transferOwnership(address newOwner) onlyOwner public {

    require(newOwner != address(0));

    emit OwnershipTransferred(owner, newOwner);

    owner = newOwner;

    }

    감사합니다.