I'm trying to transfer USDT tokens from my metamask account to another address(which is variable in smart contract) through method call.
if I use transfer method, I'm getting not enough balance(because it refers to balance of smart contract not my metamask wallet). If I use transferFrom I'm getting error saying transfer amount exceeds allowance. So I'm trying to understand what I'm doing wrong
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);
}
}