TokenTimelock.sol 1019 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. pragma solidity ^0.4.18;
  2. import "./ERC20Basic.sol";
  3. import "../token/SafeERC20.sol";
  4. /**
  5. * @title TokenTimelock
  6. * @dev TokenTimelock is a token holder contract that will allow a
  7. * beneficiary to extract the tokens after a given release time
  8. */
  9. contract TokenTimelock {
  10. using SafeERC20 for ERC20Basic;
  11. // ERC20 basic token contract being held
  12. ERC20Basic public token;
  13. // beneficiary of tokens after they are released
  14. address public beneficiary;
  15. // timestamp when token release is enabled
  16. uint256 public releaseTime;
  17. function TokenTimelock(ERC20Basic _token, address _beneficiary, uint256 _releaseTime) public {
  18. require(_releaseTime > now);
  19. token = _token;
  20. beneficiary = _beneficiary;
  21. releaseTime = _releaseTime;
  22. }
  23. /**
  24. * @notice Transfers tokens held by timelock to beneficiary.
  25. */
  26. function release() public {
  27. require(now >= releaseTime);
  28. uint256 amount = token.balanceOf(this);
  29. require(amount > 0);
  30. token.safeTransfer(beneficiary, amount);
  31. }
  32. }