22 lines
565 B
Solidity
22 lines
565 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;
|
|
constructor(address bank_addr) {
|
|
bank = Bank(payable(bank_addr));
|
|
}
|
|
|
|
function withdraw(uint amount) public {
|
|
if(address(this).balance <= 0.1 ether) {
|
|
bank.withdraw(0.5 ether);
|
|
}
|
|
require(amount<=0.1 ether, "You request amount cannot bigger than 0.1 ether");
|
|
require(amount<=address(this).balance, "This ATM doesn't have enough ETH to withdraw");
|
|
payable(msg.sender).transfer(amount);
|
|
}
|
|
}
|