Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.18;
- contract Will {
- address public owner;
- address public beneficiary;
- uint256 public deathTimeout = 20 seconds;
- uint256 public lastSignOfLife;
- function Will(address _beneficiary) public{
- owner = msg.sender;
- beneficiary = _beneficiary;
- ImAlive();
- }
- function ImAlive() public {
- require(msg.sender == owner);
- lastSignOfLife = now;
- }
- function withdrawUponDeath() public {
- require(now > lastSignOfLife + deathTimeout);
- beneficiary.transfer(address(this).balance);
- }
- function withdrawWhenAlive(uint256 _amount) public {
- require(owner == msg.sender);//only owner can do this
- msg.sender.transfer(_amount);
- }
- function () payable public {
- }
- function getBalance() public view returns(uint256) {
- return address(this).balance;
- }
- }
Add Comment
Please, Sign In to add comment