TokenTimelock.sol 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. pragma solidity ^0.4.23;
  2. import "./SafeERC20.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. using SafeERC20 for ERC20Basic;
  10. // ERC20 basic token contract being held
  11. ERC20Basic public token;
  12. // beneficiary of tokens after they are released
  13. address public beneficiary;
  14. // timestamp when token release is enabled
  15. uint256 public releaseTime;
  16. constructor(ERC20Basic _token, address _beneficiary, uint256 _releaseTime) public {
  17. // solium-disable-next-line security/no-block-members
  18. require(_releaseTime > block.timestamp);
  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. // solium-disable-next-line security/no-block-members
  28. require(block.timestamp >= releaseTime);
  29. uint256 amount = token.balanceOf(this);
  30. require(amount > 0);
  31. token.safeTransfer(beneficiary, amount);
  32. }
  33. }