I’m trying to estimate gas required to transfer usdt using Infura node but always receive gas required exceeds allowance (12451164) or always failing transaction error. I have tried both using web3 and post (via axios) and both return same error.
Hi @Vallo - you can also check out this thread from earlier this year where someone was having a similar issue. If the capping of gas limit doesn’t seem to be the issue, I would suggest checking the contract size.
@serena I can’t understand why I need to pass the “gas” parameter, since that is the value I want to estimate. Anyway, whatever value I put on “gas” parameter gets rejected and said value appears on the message 'gas required exceeds allowance (100000) or always failing transaction'
@Leiya_Kenney I don’t think that is the problem, as the contract I’m using is USDT. Don’t know the contract size but should definitely not be exceedingly big.
I have the impression something is wrong with the “data” parameter, which comes from this line
const data = await contract.methods.transfer(to, amount).encodeABI()
Yet when signing a transaction, the dataparameter on the rawTx is obtained exactly the same way. Creating, signing and broadcasting a transaction works flawlessly: I am able to transfer USDT or Dai to another wallet. The only thing that fails is estimating the gas, which I have hardcoded as a temporary workaround.
Got it, and thanks for including the steps to reproduce the error! I’ve been playing around with it, and it seems to work with the address and Uint256 amounts I tried out.
Based on that, I believe the issue stems from that “gas required exceeds allowance” part of the message, as the rest of it all works fine when I try it out on my end. Are you able to increase your gas limit in your config file?
I used just the example transfer from our docs, and the Uint256 value was 1,000,000. One thing I noticed, however, was that when I first started trying it out on my side, I ran into the same error message you were getting, but when I tried some lower values that gave me a response I was expecting and went back to that higher value, it then started to work.
I would suggest trying that tactic out and let us know how that works!
Try to remove gasPrice from your estimateGas parameter or deposit some eth into your account.
We (ThunderCore) met this error too. After analysis, we think it’s due to the upgrade of ethereum. If the gasPrice is given, estimateGas will check your balance and adjust the hi gas. This will lower the upper bound of gas and cause this problem. The higher gas price you give, the lower allowance will be returned.