added example use-case for Inheritable.sol
This commit is contained in:
committed by
Alejandro Santander
parent
b709206f9f
commit
a613cd03c9
34
contracts/examples/SimpleSavingsWallet.sol
Normal file
34
contracts/examples/SimpleSavingsWallet.sol
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user