TokenTimelock.sol 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. pragma solidity ^0.4.11;
  2. import './ERC20Basic.sol';
  3. /**
  4. * @title TokenTimelock
  5. * @dev TokenTimelock is a token holder contract that will allow a
  6. * beneficiary to extract the tokens after a given release time
  7. */
  8. contract TokenTimelock {
  9. // ERC20 basic token contract being held
  10. ERC20Basic token;
  11. // beneficiary of tokens after they are released
  12. address beneficiary;
  13. // timestamp when token release is enabled
  14. uint64 releaseTime;
  15. function TokenTimelock(ERC20Basic _token, address _beneficiary, uint64 _releaseTime) {
  16. require(_releaseTime > now);
  17. token = _token;
  18. beneficiary = _beneficiary;
  19. releaseTime = _releaseTime;
  20. }
  21. /**
  22. * @notice Transfers tokens held by timelock to beneficiary.
  23. * Deprecated: please use TokenTimelock#release instead.
  24. */
  25. function claim() {
  26. require(msg.sender == beneficiary);
  27. release();
  28. }
  29. /**
  30. * @notice Transfers tokens held by timelock to beneficiary.
  31. */
  32. function release() {
  33. require(now >= releaseTime);
  34. uint256 amount = token.balanceOf(this);
  35. require(amount > 0);
  36. token.transfer(beneficiary, amount);
  37. }
  38. }