I'm trying to transfer USDT tokens from my metamask account to another address(which is variable in smart contract) through a method call.
If I use transferFrom I'm getting an error saying the transfer amount exceeds the allowance. So I'm trying to understand what I'm doing wrong. I've tried giving allowance to msg.sender, address(this), usdtTokenAddress but nothing worked.
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
using SafeERC20 for IERC20;
contract Shop{
address usdtContractAddress;
address usdtWalletOfShop;
function approve(uint128 amount) public {
IERC20(usdtContractAddress).approve(address(this), amount);
}
function order(uint128 amount) public {
// IERC20((usdtContractAddress)).transfer(usdtWalletOfShop, amount);
IERC20((usdtContractAddress)).transferFrom(msg.sender, usdtWalletOfShop, amount);
usdtBalanceOfShop += amount;
orderId += 1;
emit Payment(msg.sender, amount, orderId);
}
}