Created
April 4, 2023 20:38
-
-
Save amarachiugwu/6a89544af91146e5aa5156fcf90744e8 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
| //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