-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.sol
30 lines (24 loc) · 829 Bytes
/
main.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract EtherWallet {
address payable public owner;
mapping(address => uint) public balances;
event Deposit(address indexed sender, uint amount);
event Withdrawal(address indexed recipient, uint amount);
constructor() {
owner = payable(msg.sender);
}
receive() external payable {
balances[msg.sender] += msg.value;
emit Deposit(msg.sender, msg.value);
}
function withdraw(uint amount) external {
require(balances[msg.sender] >= amount, "Insufficient balance");
balances[msg.sender] -= amount;
owner.transfer(amount);
emit Withdrawal(msg.sender, amount);
}
function getBalance(address account) external view returns (uint) {
return balances[account];
}
}