Here is my function for transfer on my bank contract. For some reason, my function keeps getting reverted on the first require statement even though I have sufficient funds. I have doubled checked that I deposit the ethereum and everything and have proper funds and copy it right but something keeps failing. Any ideas what is wrong?
function transfer(address recipient, uint amount) public {
require(balance[msg.sender] >= amount, "Balance not sufficient");
require(msg.sender != recipient, "Don't transfer money to yourself");
uint previousSenderBalance = balance[msg.sender];
_transfer(msg.sender, recipient, amount);
governmentInstance.addTransaction(msg.sender, recipient, amount);
emit balanceTransferred(amount, recipient);
assert(balance[msg.sender] == previousSenderBalance - amount);
}
Here is what the error is saying:
transact to Bank.transfer errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.