Implement a smart contract for shared wealth management for couples.
Alice and Bob create a contract with 10 ether initial balance. 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 normally they can only withdraw 1 ether at a time.
One day, Bob needs to withdraw 10 ether. After they have discussed this, Alice approves a single withdraw over the limit setting 10 ether as the maximum withdraw amount. Bob can now withdraw 1 ether. If Bob tries to withdraw over the limit again, he will fail.
constructor: function WealthManager(address partner2) payable
msg.sender
) is the first partner.partner2
is the second partner.withdraw: function withdraw(uint256 amount)
amount
wei to the sender of the transaction.amount
is not over the associated withdraw limit or the other partner has approved this transaction.sign: function sign(uint256 maxAmount)
maxAmount
wei.maxAmount
wei.fallback: function () payable
pragma solidity ^0.4.21;
contract WealthManager {
// <contract_variables>
// </contract_variables>
function WealthManager(address partner2) public payable {
// TODO
}
function withdraw(uint256 amount) public {
// TODO
}
function sign(uint256 maxAmount) public {
// TODO
}
function () public payable {
// TODO
}
}