Last active
July 23, 2016 19:52
-
-
Save kidwai/4b16f22c9c4442491b251b65a572bbd7 to your computer and use it in GitHub Desktop.
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
Will Src | |
contract Token { | |
event Transfer(address indexed _from, address indexed _to, uint256 _value); | |
function Token(uint256 _initialAmount) { | |
balances[msg.sender] = _initialAmount; | |
totalSupply = _initialAmount; | |
} | |
function () { | |
throw; | |
} | |
function transfer(address _to, uint256 _value) returns (bool success) { | |
if (balances[msg.sender] >= _value && _value > 0) { | |
balances[msg.sender] -= _value; | |
balances[_to] += _value; | |
Transfer(msg.sender, _to, _value); | |
return true; | |
} else { return false; } | |
} | |
function balanceOf(address _owner) constant returns (uint256 balance) { | |
return balances[_owner]; | |
} | |
mapping (address => uint256) balances; | |
mapping (address => mapping (address => uint256)) allowed; | |
uint256 public totalSupply; | |
} | |
contract Will { | |
uint256 public timestamp; | |
uint256 public constant expiration = 60*1000; | |
address public owner; | |
Token T; | |
event Update(uint _timestamp); | |
event Death() | |
mapping (address => uint) public deathMap; //recipients => amount they will get | |
address[] public recipients; | |
function Will(address _tokenAddress) { | |
owner = msg.sender; | |
T = Token(_tokenAddress); | |
timestamp = block.timestamp; | |
} | |
function () | |
function assign(address _to, uint _amount) { | |
deathMap[_to] = _amount; | |
recipients.push(_to); | |
} | |
function live() onlyOwner { | |
timestamp = now; | |
Update(timestamp); | |
} | |
function die () { | |
for (var i = 0; i < recipients.length; i++) | |
T.transfer(recipients[i], deathMap[recipients[i]]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment