Implement a smart contract for shared wealth management for families.
Alice and Bob create a contract with 10 ether initial balance, giving access to their daughter, Claire. Every time they receive their salary, they transfer it to the contract.
Every time they need money, they withdraw money from the contract, knowing that Alice and Bob can only withdraw 1 ether at a time. When Claire needs 0.1 ether, first one of the parents approves a withdrawal with a maximum amount of 0.1 ether, then Claire can withdraw the amount.
constructor: function WealthManager(address parent2, address child) payable
msg.sender
) is the first parent.parent2
is the second parent.child
is the child.withdraw: function withdraw(uint256 amount)
amount
wei to the sender of the transaction.amount
is not over the associated withdraw limit, or the sender is the child and the withdrawal has been approved/signed by one of the parents.sign: sign(uint256 maxAmount)
maxAmount
wei for the child.fallback: function () payable
pragma solidity ^0.4.21;
contract WealthManager {
// <contract_variables>
// </contract_variables>
function WealthManager(address parent2, address child) public payable {
// TODO
}
function withdraw(uint256 amount) public {
// TODO
}
function sign(uint256 maxAmount) public {
// TODO
}
function () public payable {
// TODO
}
}