From a613cd03c9e31dbc229cb5fea70a1bd8e993f2e0 Mon Sep 17 00:00:00 2001 From: zava Date: Mon, 27 Nov 2017 01:40:47 -0300 Subject: [PATCH] added example use-case for Inheritable.sol --- contracts/examples/SimpleSavingsWallet.sol | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 contracts/examples/SimpleSavingsWallet.sol diff --git a/contracts/examples/SimpleSavingsWallet.sol b/contracts/examples/SimpleSavingsWallet.sol new file mode 100644 index 00000000000..f7f55c3cb2b --- /dev/null +++ b/contracts/examples/SimpleSavingsWallet.sol @@ -0,0 +1,34 @@ +pragma solidity ^0.4.11; + +import "../ownership/Inheritable.sol"; + + +/** + * @title SimpleSavingsWallet + * @dev Simplest form of savings wallet that can be inherited if owner dies. + */ +contract SimpleSavingsWallet is Inheritable { + + event Sent(address payee, uint amount, uint balance); + event Received(address payer, uint amount, uint balance); + + + function SimpleSavingsWallet(uint _heartbeatTimeout) Inheritable(_heartbeatTimeout) public {} + + /** + * @dev wallet can receive funds. + */ + function () public payable { + Received(msg.sender, msg.value, this.balance); + } + + /** + * @dev wallet can send funds + */ + function sendTo(address payee, uint amount) public onlyOwner { + require(payee != 0 && payee != address(this)); + require(amount > 0); + payee.transfer(amount); + Sent(payee, amount, this.balance); + } +} \ No newline at end of file