Add Events in the SharedWallet Smart Contract¶
Obviously we also want to have events in our shared wallet, when someone deposits or withdraws funds:
contract SharedWallet is Allowance {
event MoneySent(address indexed _beneficiary, uint _amount);
event MoneyReceived(address indexed _from, uint _amount);
function withdrawMoney(address payable _to, uint _amount) public ownerOrAllowed(_amount) {
require(_amount <= address(this).balance, "Contract doesn't own enough money");
if(!isOwner()) {
reduceAllowance(msg.sender, _amount);
}
emit MoneySent(_to, _amount);
_to.transfer(_amount);
}
receive() external payable {
emit MoneyReceived(msg.sender, msg.value);
}
}