I have the following function and when I execute it is returning an error, any idea why?

function BuyPilaWithUSDT(uint256 _amtUSDT) external {
    require(_amtUSDT > 0, "Unsuitable Amount"); 
    require(tx.origin == msg.sender,"caller is a contract");
    uint256 amtPILA=getBuyingPrice(_amtUSDT);

Error when calling from Remix: Returned error: {"jsonrpc":"2.0","error":"execution reverted: SafeERC20: low-level call failed","id":4615488695460828}

I noticed that in Remix it is noting the function as "infinite gas". Is there any infinite loop that I am not seeing ?

Here is the transaction in the Sepolia test network: https://sepolia.etherscan.io/tx/0x6dadc41bb177e82772bf6d7122ec3b0e969012e43a0350c02a5a8bf69ac8ea9b

Here is the contract itself in Sepolia: https://sepolia.etherscan.io/address/0x2680553541866E2b4431e8215a7a6F8856836A14

Intention: This contract currently holds 100000 PILA tokens, given an amount of USDT tokens it should calculate the rate and transfer the USDT from the sender to the contract and send the calculated amount in PILA from the contract to the sender, it is basically to sell coins for an ICO.

1 Answer 1


Looks like the contract does not have an approval to transfer any USDTs from the caller to itself. You need to run an approval transaction first. enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.