pragma solidity ^0.4.18; contract Bank { // Mapping to store balances of each account mapping(address => uint256) private balances; // Event to log deposits event Deposit(address indexed account, uint256 amount); // Event to log withdrawals event Withdraw(address indexed account, uint256 amount); // Function to deposit money function deposit() public payable { require(msg.value > 0); balances[msg.sender] += msg.value; Deposit(msg.sender, msg.value); } // Function to withdraw money function withdraw(uint256 amount) public { require(amount > 0); require(balances[msg.sender] >= amount); balances[msg.sender] -= amount; msg.sender.transfer(amount); Withdraw(msg.sender, amount); } // Function to check the balance of the caller function getBalance() public view returns (uint256) { return balances[msg.sender]; } }
0.4.18