SimpleTimelock is an ETH holder contract that will allow a beneficiary to extract the ETH after a given release time.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.5.0; | |
/** | |
* @title SimpleTimelock | |
* @dev SimpleTimelock is an ETH holder contract that will allow a | |
* beneficiary to receive the ETH after a given release time. | |
*/ | |
contract SimpleTimelock { | |
// beneficiary of ETH after it is released | |
address payable public beneficiary; | |
// timestamp when ETH release is enabled | |
uint256 public releaseTime; | |
// accept incoming ETH | |
function () external payable {} | |
constructor (address payable _beneficiary, uint256 _releaseTime) public { | |
require(_releaseTime > block.timestamp, "release time is before current time"); | |
beneficiary = _beneficiary; | |
releaseTime = _releaseTime; | |
} | |
// transfers ETH held by timelock to beneficiary. | |
function release() public { | |
require(block.timestamp >= releaseTime, "current time is before release time"); | |
uint256 amount = address(this).balance; | |
require(amount > 0, "no ETH to release"); | |
beneficiary.transfer(amount); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment