Created
April 8, 2018 10:14
-
-
Save eternnoir/bdf9aadde1c9b0189f103a6dc3f8b542 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.4.16; | |
contract Atm { | |
mapping(address => bool) public withdrawer; | |
uint256 public basicAmount; | |
address public owner; | |
function Atm() public payable { | |
owner = msg.sender; | |
} | |
modifier onlyOwner() { | |
require(msg.sender == owner); | |
_; | |
} | |
function changeBaicAmount(uint256 newAmount) public onlyOwner { | |
basicAmount = newAmount; | |
} | |
function withdraw() public payable returns(bool success) { | |
require(!withdrawer[msg.sender]); | |
require(address(this).balance > basicAmount); | |
msg.sender.transfer(basicAmount); | |
withdrawer[msg.sender] = true; | |
return true; | |
} | |
function balance() public view returns(uint256) { | |
return address(this).balance; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment