Skip to content

Instantly share code, notes, and snippets.

@nourharidy
Last active December 3, 2018 07:38
Show Gist options
  • Save nourharidy/7ece6bb4311f5484635a4edd816aae9c to your computer and use it in GitHub Desktop.
Save nourharidy/7ece6bb4311f5484635a4edd816aae9c to your computer and use it in GitHub Desktop.
Simple HODLer contract. Written in 10mins. Passed static analysis but is not guaranteed to be safe.
pragma solidity ^0.5.0;
contract HODLer {
uint releaseDate;
address owner;
// Contract deployer specifies deposit release date in constructor
constructor(uint secondsSince1971) public {
releaseDate = secondsSince1971;
owner = msg.sender;
}
// Anyone can deposit simply by sending ether to the contract address
function () payable external;
// Only owner can withdraw all Ether after releaseDate has passed
function withdraw() public {
require(msg.sender == owner);
require(now > releaseDate);
msg.sender.transfer(address(this).balance);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment