Skip to content

Instantly share code, notes, and snippets.

@amarachiugwu
Created April 4, 2023 20:38
Show Gist options
  • Select an option

  • Save amarachiugwu/6a89544af91146e5aa5156fcf90744e8 to your computer and use it in GitHub Desktop.

Select an option

Save amarachiugwu/6a89544af91146e5aa5156fcf90744e8 to your computer and use it in GitHub Desktop.
//SPDX-License-Identifier:MIT
pragma solidity 0.8.5;
contract ATMMachine {
// this is the reserve of the atm machine
address public owner;
constructor () {
owner = msg.sender;
}
mapping (address => uint) public userBal;
modifier onlyOwner() {
require (msg.sender == owner, 'Not the owner');
_;
}
function deposit (address addr, uint amt) onlyOwner payable public {
userBal[addr] = amt;
}
function withdrawl (uint _amt) public payable {
require(userBal[msg.sender] >= _amt, 'you cannot withdrawl more than you have');
require(_amt <= address(this).balance, 'Temporally unable to dispense cash');
userBal[msg.sender] -= _amt;
payable(msg.sender).transfer(_amt);
}
function constractBal() public view returns(uint){
return address(this).balance;
}
}
//10000000000000000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment