I am trying to develop a buy function for my token smart contract, but it fails on the transfer:
transfer(msg.sender, amountToBuy);
It fails with the Error: 'ERC20: transfer amount exceeds balance'
, even though the contract has enough tokens in its balance: