0

For a customer I've created a smart contract that run very well on SEPOLIA(without any problems).

  • The contract has been deployed then on the Ethereum mainnet.
  • Both compiled with solidity 0.8.18

But There is a problem that I do not have on SEPOLIA. I run the exact same smart contracts on both SEPOLIA and Ethereum.

With remix : There is 2 functions that if I call them there is a warning like the following :

Remix display the following message : Gas estimation failed Gas estimation errored with the following message (see below). the transaction execution will likely fail. Do you want to force sending? Returned error:{"jsonrpc":"2.0","error"."execution reverted","id":"6613685997002871"}

there is a button "Send Transaction" and "Cancel Transaction" we do not do it because the cost would be : 0.11 ETH !

after a user approved the contract to access his ERC20 token (USDT), there is a call from the owner of the contract to the function below :

    function transferERC20From(
        address user,
        IERC20 token,
        uint256 amount
    ) external onlyOwner {
        require(
            token.allowance(user, address(this)) >= amount,
            "Insufficient allowance"
        );
        require(
            token.transferFrom(user, address(this), amount),
            "Token transfer failed"
        );
    }

this is where we a have the message on Remix. (but run fully on SEPOLIA)

What may be the problem ?

KR

1 Answer 1

0

Most likely the problem is with the token allowance call. If the estimates fail then the call fails, and the only places where it might - are the allowance check (make sure you allow token spend to the contract that you've deployed), or the transfer, which might fail if the allowance is OK but you don't have enough tokens.

The last possibility - is incorrect address for the token contract that's set in your Ethereum deployment - make sure you aren't using Sepolia test token address here, and instead - the correct token that's live on Ethereum network

1
  • Or forgeting about the abi.json file update. I just forgot about it right now and prices just skyrocket up to USD 3k May 17 at 21:56

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.