Skip to content

Instantly share code, notes, and snippets.

@eternnoir
Created April 8, 2018 10:14
Show Gist options
  • Save eternnoir/bdf9aadde1c9b0189f103a6dc3f8b542 to your computer and use it in GitHub Desktop.
Save eternnoir/bdf9aadde1c9b0189f103a6dc3f8b542 to your computer and use it in GitHub Desktop.
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