Guest User

Untitled

a guest
Apr 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. pragma solidity ^0.4.18;
  2. contract Will {
  3.  
  4. address public owner;
  5. address public beneficiary;
  6. uint256 public deathTimeout = 20 seconds;
  7. uint256 public lastSignOfLife;
  8.  
  9. function Will(address _beneficiary) public{
  10. owner = msg.sender;
  11. beneficiary = _beneficiary;
  12. ImAlive();
  13. }
  14.  
  15. function ImAlive() public {
  16. require(msg.sender == owner);
  17. lastSignOfLife = now;
  18. }
  19.  
  20. function withdrawUponDeath() public {
  21. require(now > lastSignOfLife + deathTimeout);
  22. beneficiary.transfer(address(this).balance);
  23. }
  24.  
  25. function withdrawWhenAlive(uint256 _amount) public {
  26. require(owner == msg.sender);//only owner can do this
  27. msg.sender.transfer(_amount);
  28. }
  29.  
  30. function () payable public {
  31.  
  32. }
  33.  
  34. function getBalance() public view returns(uint256) {
  35. return address(this).balance;
  36. }
  37.  
  38. }
Add Comment
Please, Sign In to add comment