I updated the Bank.sol contract I already had and updated the pragma solidity to 0.8.0 so they all worked.
pragma solidity 0.8.0;
import "./Ownable.sol";
import "./SafeMath.sol";
interface GovernmentInterface{
function addTransaction(address _from,address _to,uint _amount) external;
}
contract Bank is Ownable {
using SafeMath for uint256;
GovernmentInterface GovernmentInstance =
GovernmentInterface(0x2557F4c8Ba4BE59eDDAbfd26dF4ECd7F2e678f1d);
mapping(address => uint) balance;
address[] customers;
event depositDone(uint amount, address indexed receivedBy);
function deposit() public payable returns (uint) {
balance[msg.sender].add(msg.value);
emit depositDone(msg.value,msg.sender);
return balance[msg.sender];
}
function getBalance() public view returns (uint){
return balance[msg.sender];
}
function withdraw(uint amount) public returns (uint){
//msg.sender is an address (payable by default)
//address payable toSend = 0x1aE0EA34a72D944a8C7603FfB3eC30a6669E454C
require(balance[msg.sender] >= amount, "You have insufficient funds!");
payable(msg.sender).transfer(amount);
balance[msg.sender].sub(amount);
return balance[msg.sender];
}
function transfer(address payable recipient, uint amount) public {
//Valuidation of balance of msg.sender
require(balance[msg.sender] >= amount, "Balance insufficient!");
//If the abve throws false, require will throw an error
// AND contract execution will be stopped.
//Prevent transferring to yourself
require(msg.sender != recipient, "Don't transfer money to yourself");
uint previousSenderBalance = balance[msg.sender];
_transfer(msg.sender,recipient,amount);
//Event Logs and Further Checks5
GovernmentInstance.addTransaction(msg.sender, recipient, amount);
assert(balance[msg.sender] == previousSenderBalance.sub(amount));
}
function _transfer(address from, address to, uint amount) private
{
balance[from] = balance[from].sub(amount);
balance[to] = balance[to].add(amount);
}
}