Closed bakatrouble closed 2 months ago
My guess is it is failing early because the estimateGas is detecting failure, which is why the transaction is failing to launch the UI. I recommend trying to set an explicit gasLimit in your transaction, and you will probably get what you expect. :)
This is a problem because then it is impossible to get the revert reason when sending via ethers, unless ethers can return the revert reason the same way it can predict the transaction will revert. Setting a constant gas limit does not seem ideal as that depends on the contract, which may change.
@rellfy The revert reason should be available from any CALL_EXCEPTION if the node returns one. Can you provide an example call that has a revert reason, but it cannot be accessed?
if it will help, here is some example data :
Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"code":-32603,"message":"execution reverted: Contract locked","data":{"originalError":{"code":3,"data":"0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000f436f6e7472616374206c6f636b65640000000000000000000000000000000000","message":"execution reverted: Contract locked"}}}, method="estimateGas", transaction={"from":"0xDb89C1C66191E6B3Af2A299fbfF2E22EB1Fe1AE0","to":"0x47A79Fe1F74eA4c3B6DE0a387e129Daa80177d3A","data":"0x854d5a4e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000012a80000000000000000000000000000000000000000000000000000000000000c1f","accessList":null}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.2.0)
Bumping this, as I'm having the same issue.
When I go to make a transaction on etherscan, I get the error in the metamask UI. I would like to mimic that experience
I am facing a similar issue
I am trying to perform txn via ethers but it returns me with UNPREDICTABLE_GAS_LIMIT
. Looking closely at the error it says not enough token funds to send transaction
, that's not the case as i mentioned above having enough balance
A complete error log is as follows
Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"name":"ProviderError","code":3,"_isProviderError":true,"data":"0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002a6e6f7420656e6f75676820746f6b656e2066756e647320746f2073656e64207472616e73616374696f6e00000000000000000000000000000000000000000000"}, method="estimateGas", transaction={"from":"0x48F29E939A0896Fd9BBC113cD7a4432A1dB33C40","to":"0x068e41E14c83C48a2B238b6dDcf31a0C12bC13B5","data":"0xad29d51500000000000000000000000083cb1597cf92f0a492be26311fd88d08cab53859000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000de76d3f38b342f988f0d73a2c6b7d1d527b3d5d000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000de0b6b3a7640000","accessList":null}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.5.2)
at Logger.makeError (/home/USER/Documents/ethereum-smart-contracts/batch-withdrawal/node_modules/@ethersproject/logger/src.ts/index.ts:225:28)
at Logger.throwError (/home/USER/Documents/ethereum-smart-contracts/batch-withdrawal/node_modules/@ethersproject/logger/src.ts/index.ts:237:20)
at checkError (/home/USER/Documents/ethereum-smart-contracts/batch-withdrawal/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:80:16)
at EthersProviderWrapper.<anonymous> (/home/USER/Documents/ethereum-smart-contracts/batch-withdrawal/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:562:20)
at step (/home/USER/Documents/ethereum-smart-contracts/batch-withdrawal/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23)
at Object.throw (/home/USER/Documents/ethereum-smart-contracts/batch-withdrawal/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53)
at rejected (/home/USER/Documents/ethereum-smart-contracts/batch-withdrawal/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:65)
at processTicksAndRejections (internal/process/task_queues.js:95:5) {
reason: 'cannot estimate gas; transaction may fail or may require manual gas limit',
code: 'UNPREDICTABLE_GAS_LIMIT',
error: ProviderError: execution reverted: not enough token funds to send transaction
at HttpProvider.request (/home/USER/Documents/ethereum-smart-contracts/batch-withdrawal/node_modules/hardhat/src/internal/core/providers/http.ts:49:19)
at LocalAccountsProvider.request (/home/USER/Documents/ethereum-smart-contracts/batch-withdrawal/node_modules/hardhat/src/internal/core/providers/accounts.ts:187:34)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at EthersProviderWrapper.send (/home/USER/Documents/ethereum-smart-contracts/batch-withdrawal/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20),
method: 'estimateGas',
transaction: {
from: '0x48F29E939A0896Fd9BBC113cD7a4432A1dB33C40',
to: '0x068e41E14c83C48a2B238b6dDcf31a0C12bC13B5',
data: '0xad29d51500000000000000000000000083cb1597cf92f0a492be26311fd88d08cab53859000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000de76d3f38b342f988f0d73a2c6b7d1d527b3d5d000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000de0b6b3a7640000',
accessList: null
}
}
@arshad-binary What network are you on? In your error, I can see Hardhat network (is that what you intended?). You can get details about the network that's being used by your script using console.log(await provider.getNetwork())
.
@zemse I am using rinkeby
(confirmed by using provider.getNetwork()
as well) & trying to use an already deployed USDC
contract address.
if it will help, here is some example data :
Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"code":-32603,"message":"execution reverted: Contract locked","data":{"originalError":{"code":3,"data":"0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000f436f6e7472616374206c6f636b65640000000000000000000000000000000000","message":"execution reverted: Contract locked"}}}, method="estimateGas", transaction={"from":"0xDb89C1C66191E6B3Af2A299fbfF2E22EB1Fe1AE0","to":"0x47A79Fe1F74eA4c3B6DE0a387e129Daa80177d3A","data":"0x854d5a4e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000012a80000000000000000000000000000000000000000000000000000000000000c1f","accessList":null}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.2.0)
same issue
@zuhairzia you are using an old version of ethers. This bug should be fixed in the recent release.
same issue using telos evm Generally I have some weird outputs of write funtions because I am using custom errors in my contract. I explained more about the problem in my discussion Ethers.js throws other errors then expected by write function and read function works as expected (Solidity custom errors)
Closing older issues. But if this is still happening in v6, please re-open or start a new issue.
Thanks! :)
Is there a way to show Metamask window even if transaction is going to fail, as it happens when using Web3 library?