Skip to content

Instantly share code, notes, and snippets.

@Austin-Williams
Last active March 5, 2024 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Austin-Williams/69bf064683c604c294addeb934c945b1 to your computer and use it in GitHub Desktop.
Save Austin-Williams/69bf064683c604c294addeb934c945b1 to your computer and use it in GitHub Desktop.
SimpleTimelock is an ETH holder contract that will allow a beneficiary to extract the ETH after a given release time.
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