0

I have this snippet to test if web3.eth.call() can check if a pending transaction will revert in advance.

web3.eth.call(tx, "pending")
.then(result => { console.log(count, "Passed!") })
.catch(revertReason => console.log(count, "Reason: ", revertReason ))

Then there are some calls on transactions that return revert error like {code: -32000, message: "err: insufficient funds for gas * price + value (supplied gas 164340)"}

or

Fail with error 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT

When I check into etherscan they were success.

Why does it happen?

1 Answer 1

0

The transaction execution result depends on the context.

Execution simulation with eth_call or estimateGas don't necessarily imply it will succeed or fail.

The uniswap transaction appears failing with insufficient amount while pending. If before being mined a third party deposit enough funds it will succeed.

Similarly a transaction in pending might fail with not enough funds, but another pending transaction may increase those funds and allow the transaction to be mined.

The pending pool changes frequently so at any moment a node might not contain all pending transactions.

2
  • does that mean theweb3.eth.call isn't really good at estimating if a pending tx will fail or not?
    – Marr
    Jan 9, 2021 at 13:35
  • @Marr It might work in many cases, but for certain type of contract it might not work. If a transaction depends on the contract state, then any change between eth_call and the transaction mined might affect the transaction final result.
    – Ismael
    Jan 9, 2021 at 16:54

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.