// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
//Import statement here - e.g ERC20 Token
import "@openzeppelin/contracts/access/Ownable.sol";
interface IERC20 {
function transfer(address _to, uint256 _value) external returns (bool);
// don't need to define other functions, only using transfer() in this case
function approve(address spender, uint256 amount) external returns (bool);
// require transferFrom
function transferFrom(address from,address to,uint256 amount) external returns (bool);
}
contract TransferUSDT is Ownable {
// ------------------------- Events -----------------------------------
event UserHasPurchased(string _name, uint256 _tokenId);
event WithdrawEth(address _to, uint256 _amount);
// ----------------------- Begin ------------------------------------
function payAmountUSDT(uint256 _amount) public {
IERC20 usdt = IERC20(address(0x01BE23585060835E02B77ef475b0Cc51aA1e0709));
// transfers USDT that belong to your contract to the specified address
usdt.transferFrom(msg.sender,address(this), _amount);
}
function withdrawEth(address payable _to) external onlyOwner {
uint256 balance = address(this).balance;
_to.transfer(balance);
emit WithdrawEth(_to, balance);
}
}
*who can tell me why this is failing - keep getting gas price estimation failed"* Yes i have approved that token to the smart contract address
Feb 22, 2022, 3:14 AM
the payAmountUSDT is failing I assume you mean? What network is this on? Are you sure the 0x01Be...0709 address is correct, that contract actually has a transferFrom function, and doesn't have code there that might make your transfer fail?
Feb 22, 2022, 6:06 AM