Replies: 26 comments 4 replies
-
It seems that your contract is reverting when you call |
Beta Was this translation helpful? Give feedback.
-
Hi @zemse sure, I tried in different environments as well. From Remix, sending the very same parameters to the same contract address, ABI, etc... the transaction completes without any issue. The only difference, is me using the wrong wallet (having tokens, but not eth) on ethers.js and the right wallet on Remix. |
Beta Was this translation helpful? Give feedback.
-
We do get an insufficient funds error if enough ETH is not present. Did you try using correct wallet in your code, did that work? But as you say you get When you run
Which means that your tx is probably reverting for that different address even if it had some ETH. Though you can confirm this to be sure. |
Beta Was this translation helpful? Give feedback.
-
Still Having The same issue (Using ethers-v5)
Not sure what I am doing wrong so here is the deployment code:
Wallet Has sufficient Test ETH |
Beta Was this translation helpful? Give feedback.
-
@brytemorio |
Beta Was this translation helpful? Give feedback.
-
I agree with @zemse. Does your contract have something in the constructor or as initializers to global variables that could cause a failure. Basically, when ethers is asking for an estimate to deploy from the nodes it is responding it cannot provide a safe estimate. If you know values that are safe, you can bake them into your execution. For example, if you know 250,000 gas is safe, you can use: token = await tokenFactory.deploy(tokenName, ticker, FinalSupply, {
gasLimit: 250000
}); this will bypass ethers attempting to estimate gas and force using that amount. You can then similarly use the same technique for the This error usually indicates that the contract deployment will fail, so it may still not succeed. However, sometimes estimation incorrectly guesses deployment will fail, especially if there are calls to external contracts, or variables like Let me know! :) |
Beta Was this translation helpful? Give feedback.
-
@ricmoo though I have longed solved the issue, bu it is as you anticipated, constructor(
string memory _tokenName,
string memory _ticker,
uint256 _supply
) ERC20(_tokenName, _ticker) QNDTokenCapped(_supply){
_setupDecimals(__decimals);
addMinter(_msgSender()); //very naive
} (the above code from the token contract) I spotted the bug patiently scanning through the erroneous json outuput, the very specific message stating what exactly the error was. One thing I however found inconvenient was that the message was mixed up in the contracts bytecode plastered all over my screen. It seems that a failure in one contract cascades into the next, at least from the way I'd deployed both in chains. Perhaps it would be much nicer to have less verbose but very specific erroneous outputs on failures.... |
Beta Was this translation helpful? Give feedback.
-
@zemse As I was saying, the transaction and the contract were both correct. Submitting the very same parameters with Remix (from the right wallet) worked flawlessly. So:
It may be a vicious circle, because you can't know if you have enough ether for a transaction until you have estimated it. And you can't estimate as estimation fails because you have insufficient funds. But at least, if the balance is exactly 0, we do know for sure that the failure to estimate is due to this. Thank you! |
Beta Was this translation helpful? Give feedback.
-
Yes I believe gas estimation will fail if a gas price is given and the If gas price isn't provided for gas estimation, this isn't taken into consideration and the gas estimation will ignore funds (unless the tx causes the funds to be moved) |
Beta Was this translation helpful? Give feedback.
-
This is a similar issue to what I am also having, even setting the gasLimit and gasPrice estimate,
|
Beta Was this translation helpful? Give feedback.
-
Do you have issues or suspect any activity on your trust wallet? You should write to the support team for assistance. I was able to get some help through this form. |
Beta Was this translation helpful? Give feedback.
-
I've done further debugging in regards to this issue. I think the main problem is that Ethers includes a For Ethers.js, when estimating the gas for a contract method:
Even though the from account has plenty of funds (testing account) the UNPREDICTABLE GAS LIMIT happened. For the same transaction using the web3.js library the
Hope this helps. Probably simplifying the |
Beta Was this translation helpful? Give feedback.
-
I agree with your input, as recently I too was facing the same issue and it was due to ERC20:Insufficient contract allowance. It can be compared to with that of Metamask, eg, if you are trying to send a transaction from Metamask which would fail then Metamask, will give you an error indicating Always failing transaction, however, it cannot predict the exact failure reason, similarly here too, as it is a failing transaction, ethers throws an error UNPREDICTABLE_GAS_LIMIT. Takeaway: Debug your transaction for any revert |
Beta Was this translation helpful? Give feedback.
-
when I use the function quoteExactInputSingle,it throws an error UNPREDICTABLE_GAS_LIMIT,do I need to change the gaslimit? |
Beta Was this translation helpful? Give feedback.
-
I'd like to add here that this message is incredibly unhelpful. I've run into this dozens of times, and basically every time it's actually an error in the contract, but Ethers gives me no information on what that error is. So every time it's just me looking through source code and taking shots in the dark over and over again. |
Beta Was this translation helpful? Give feedback.
-
It might be possible, depending on what the node itself returns. Ethers makes its best attempt to parse out the information from the response, but nodes keep changing the formatting, strings and other things. If you can provide the response from the node and it is present there, I can add code to try sniffing it out. But keep in mind that Truffle, I believe, is running their own instance of an EVM engine, so it has access to the internal state of the memory, stack, call stack, and call status when it is composing an error message, which may be why they can provide a more concise error message. Just a guess. I haven't used Truffle in a few years, so my memory may be foggy. :) |
Beta Was this translation helpful? Give feedback.
-
I was doing this on a Rinkeby transaction, so I don't think it was with their own EVM engine. Next time I run into this I'll see if I can get a node response. |
Beta Was this translation helpful? Give feedback.
-
I got an const contract = new ethers.Contract(address, abi, provider);
await contract.deployed();
console.log(await contract.name()); I found this out by checking that the contract code locally matched the deployed contract code. ethereum.request({
method: 'eth_getCode',
params: [address] }
).then(console.log) ...where I ran this with MetaMask connected to localhost and mainnet and compared the results. |
Beta Was this translation helpful? Give feedback.
-
If that can help anyone, for me the error was that I had an error in my contract using the Solidity
|
Beta Was this translation helpful? Give feedback.
-
I experienced the UNPREDICTABLE_GAS_LIMIT error in the following two scenarios:
|
Beta Was this translation helpful? Give feedback.
-
I get same errors, but some times is worked and other not, My wallet has 0.018 ETH and 26 USDT, when I try to calculate gas, I do this:
some times this returns a value but others not RESULT 55197 //OK |
Beta Was this translation helpful? Give feedback.
-
Having the same error when trying to retrieve ERC20 token info, after deleting the function of that, it goes well. |
Beta Was this translation helpful? Give feedback.
-
Is there no way to reliably surface the reason for transactions failing, in the case that it is a transaction failure? Would be extremely helpful to see the |
Beta Was this translation helpful? Give feedback.
-
You're either in the wrong network or your contract address is invalid i had that error before when i forgot to mention rinkeby while deploying the contract. |
Beta Was this translation helpful? Give feedback.
-
I got "cannot estimate gas; transaction may fail or may require manual gas limit" error and if you are working with hardhat deleting cache and artifacts folder might help, hardhat regenerates it and same code works flawless after that. If you get the same error after doing this double, triple, quadruple check your revert or require statements or even the whole function you are calling. |
Beta Was this translation helpful? Give feedback.
-
Hey bro i dont know if you tried this already but, you are trying to interact with the contract without passing the maxFeePerGas and maxPriorityFeePerGas. So here what it should look like. await myTransaction(
[...params],
{
maxFeePerGas,
maxPriorityFeePerGas,
},
); So in order to you get those values at least on polygon network they provide a gasStation so you can fetch for it and get its current value. It would look like this: async calcGas() {
let maxFeePerGas = BigNumber.from('40000000000'); // fallback to 40 gwei
let maxPriorityFeePerGas = BigNumber.from('40000000000'); // fallback to 40 gwei
try {
const { data } = await axios({ method: 'get', url: this.gasStationUrl });
maxFeePerGas = utils.parseUnits(Math.ceil(data.fast.maxFee) + '', 'gwei');
maxPriorityFeePerGas = utils.parseUnits(
Math.ceil(data.fast.maxPriorityFee) + '',
'gwei',
);
} catch (e) {
throw new Error();
}
// send tx with custom gas
return { maxFeePerGas, maxPriorityFeePerGas };
} Hopefully it helps you. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Launching a transaction to the Goerli network, I have been getting this error:
The transaction is launched like:
At first I checked #484 as a potential duplicate.
However, the real error is that the account sending the transaction holds no ether. Nothing related to failing transactions or similar.
In such cases, it would be nice to detect the insufficient or null balance and warn about this instead of the unpredictable gas limit message alone.
BTW, thank you for such a great library!
Beta Was this translation helpful? Give feedback.
All reactions