0

I have deployed a Flash Loan Arbitrage smart contract on BSC Testnet. I then loaded 1 BNB on smart contract now when I call a function of Smart Contract it gives me the following error.

"Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? Internal JSON-RPC error. { "code": -32000, "message": "execution reverted" }"

function startArbitrage(
    address token0, 
    address token1, 
    uint amount0, 
    uint amount1
  ) external {
    address pairAddress = IUniswapV2Factory(pancakeFactory).getPair(token0, token1);
    emit test_value(pairAddress); // log the current value
    
    require(pairAddress != address(0), 'This pool does not exist');
    IUniswapV2Pair(pairAddress).swap(
      amount0, 
      amount1, 
      address(this), 
      bytes('not empty')
    );
  }
0

This just means the code will revert if you actually send the transaction. Sadly, it doesn't show you what the revert message would be, so you can't debug it from this message alone.

You could easy force the transaction to be sent, by specifying the exact gas to be used, then looking at the resulting revert message when it is mined, or use some kind of simulator (perhaps https://tenderly.co) to find out what is going wrong without actually paying.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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