Implement a smart contract for giving pocket money to a child.
Alice and Bob create a contract with 10 ether initial balance, giving access to their daughter, Claire. On the first day of every month, Claire withdraws 0.1 ether as her pocket money. If she tries to withdraw again during the month, she fails. If Alice or Bob needs some money, they can freely withdraw any amount from the contract.
constructor: function PocketMoney(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, and at least 4 weeks have passed since the last withdraw by the child.fallback: function () payable
pragma solidity ^0.4.21;
contract PocketMoney {
// <contract_variables>
// </contract_variables>
function PocketMoney(address parent2, address child) public payable {
// TODO
}
function withdraw(uint256 amount) public {
// TODO
}
function () public payable {
// TODO
}
}