I'm trying to create a vault smart-contract that allows deposits and withdraws of Tron USDT. Deposits - work.
But when I try to withdraw, I get ERC20 transfer amount exceedes balance error..... but I gave allowance! like this:
spender = msg.sender; usdt.approve(spender, amount);
And it confirms on blockchain that I gave allowance for SC to spend funds on user behalf. Then I try:
usdt.transferFrom(address(this), recipient, amount);
And it fails! And
usdt.transfer(recipient, amount)
fails too!