23 lines
586 B
Solidity
23 lines
586 B
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity >=0.4.22 <0.9.0;
|
|
|
|
import "./BaseContract.sol";
|
|
import "./Bank.sol";
|
|
|
|
contract ATM is BaseContract{
|
|
Bank bank;
|
|
event Withdraw(address from, uint amount, uint balance );
|
|
constructor(address bank_addr) {
|
|
bank = Bank(payable(bank_addr));
|
|
}
|
|
|
|
function withdraw(uint amount) public {
|
|
require(amount<=0.1 ether, "You cannot withdraw more than 0.1 ether");
|
|
if(address(this).balance <= 0.1 ether) {
|
|
bank.withdraw(0.5 ether);
|
|
}
|
|
payable(msg.sender).transfer(amount);
|
|
emit Withdraw(msg.sender, amount, address(this).balance);
|
|
}
|
|
}
|