0

I'm getting gas estimation errors leading to my transactions not going through. Here is the error message:

Error: processing response error (body="{\"jsonrpc\":\"2.0\",\"id\":256,\"error\":{\"code\":3,\"message\":\"execution reverted\",\"data\":\"0x\"}}", error={"code":3,"data":"0x"}, requestBody="{\"method\":\"eth_estimateGas\",\"params\":[{\"from\":\"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266\",\"to\":\"0x2ce1F0e20C1f69E9d9AEA83b25F0cEB69e2AA2b5\",\"data\":\"0x2fe69784000000000000000000000000000000000000000000000000000bd342d3875ed9000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f\",\"value\":\"0x0\",\"type\":\"0x2\",\"maxFeePerGas\":\"0x60f7b0ba\"},\"latest\"],\"id\":256,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="http://127.0.0.1:1234", code=SERVER_ERROR, version=web/5.7.1)

I read a similar problem on Go-Ethereum EstimateGas Errors that the "To" field was an unknown address and making sure a valid "To" address is defined will solve this issue. However, I'm not defining this "To" address anywhere in my code.

This is my Solidity code:

IUniswapV2Router router = IUniswapV2Router(routerAddress);
IERC20(swapPaths[0]).approve(routerAddress, type(uint256).max);
router.swapExactTokensForTokens(amountIn, 0, swapPaths, address(this), block.timestamp);
IERC20(swapPaths[0]).approve(routerAddress, 0);

Where routerAddress is 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D (because I'm swapping on Uniswap v2) amountIn and swapPaths varies, but an example that triggers a gas estimation failure error is 3328508713983705 and [0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, 0x630d98424efe0ea27fb1b3ab7741907dffeaad78, 0xae7ab96520de3a18e5e111b5eaab095312d7fe84, 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2] respectively.

My question - is 0x2ce1F0e20C1f69E9d9AEA83b25F0cEB69e2AA2b5 coming from Geth? Perhaps its used as a default value when no "To" address is defined? If so, what should this "To" address be?

0

Your Answer

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

Browse other questions tagged or ask your own question.