solidity/test/compilationTests/zeppelin/token/TokenTimelock.sol

42 lines
939 B
Solidity
Raw Normal View History

2017-07-05 10:28:15 +00:00
pragma solidity ^0.4.11;
import './ERC20Basic.sol';
/**
* @title TokenTimelock
* @dev TokenTimelock is a token holder contract that will allow a
* beneficiary to extract the tokens after a given release time
*/
contract TokenTimelock {
// ERC20 basic token contract being held
ERC20Basic token;
// beneficiary of tokens after they are released
address beneficiary;
// timestamp when token release is enabled
uint releaseTime;
2018-07-04 17:20:51 +00:00
constructor(ERC20Basic _token, address _beneficiary, uint _releaseTime) public {
2017-07-05 10:28:15 +00:00
require(_releaseTime > now);
token = _token;
beneficiary = _beneficiary;
releaseTime = _releaseTime;
}
/**
* @dev beneficiary claims tokens held by time lock
*/
2018-07-04 17:20:51 +00:00
function claim() public {
2017-07-05 10:28:15 +00:00
require(msg.sender == beneficiary);
require(now >= releaseTime);
uint amount = token.balanceOf(this);
require(amount > 0);
token.transfer(beneficiary, amount);
}
}