Created
March 17, 2019 00:59
-
-
Save Zizzamia/3b8fbaaf9aeaf97e5d36f26d7634788e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.5.0; | |
contract SimpleBank { | |
mapping (address => uint) private balances; | |
address public owner; | |
constructor() public { | |
owner = msg.sender; | |
} | |
function deposit() public payable returns (uint256) { | |
require((balances[msg.sender] + msg.value) >= balances[msg.sender]); | |
balances[msg.sender] += msg.value; | |
return balances[msg.sender]; | |
} | |
function withdraw(uint256 withdrawAmount) public returns (uint256 remainingBal) { | |
require(withdrawAmount <= balances[msg.sender]); | |
balances[msg.sender] -= withdrawAmount; | |
msg.sender.transfer(withdrawAmount); | |
return balances[msg.sender]; | |
} | |
function balance() constant public returns (uint256) { | |
return balances[msg.sender]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment