question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

estimateGas call fails in optimism network.

See original GitHub issue

Description : estimateGas call fails if I try optimism rpc endpoints, with others it’s successfully returning the result.

I’m using “ethers”: “^5.5.3” version in my project, and while trying the following code I get the error: Error: gas required exceeds allowance

const ethers = require('ethers')
async function test() {
  let url
  url = 'https://kovan.optimism.io'
  // url = 'https://polygon-rpc.com'
  // url ="https://kovan.poa.network"
  // url = 'https://rinkeby.arbitrum.io/rpc'
  // url = 'https://mainnet.optimism.io'
  
  
  let provider=  new ethers.providers.JsonRpcProvider(url)
  const gasPrice =await provider.getGasPrice();
  const tx = {
    to: '0xb4DE0833771eae55040b698aF5eB06d59E142C82',     
    value: '0x1',
  }
  const estimatedGas = await provider.estimateGas(tx);
  
  console.log(gasPrice.toString())
  console.log(estimatedGas.toString())
}

test()

Here’s the full error that I am getting. image

All the other endpoints works fine except the optimism ones. Can anyone suggest if I am doing something wrong?

Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
smartcontractscommented, Mar 1, 2022

We (the Optimism team) did additional research and found that this was an issue over at QuickNode, the RPC provider behind both mainnet.optimism.io and kovan.optimism.io. QuickNode upgraded its infrastructure over the last few days and it seems that this problem has been fixed along with that upgrade. This can safely be closed as it’s not an issue with ethers.js and it’s also been fixed.

1reaction
smartcontractscommented, Jan 10, 2022

I think this is probably an issue with some quirk in the Optimism node and unlikely to be an Ethers issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

transaction may fail or may require manual gas limit - Contracts
When i execute this script, i get this following error. { Error: cannot estimate gas; transaction may fail or may require manual gas...
Read more >
transaction may fail or may require manual gas limit" : r/ethdev
I am trying a mint function that I wrote and getting this error: Error: cannot estimate gas; transaction may fail or may require...
Read more >
eth_estimateGas - Alchemy Docs
Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added...
Read more >
Asking for "Gas estimation failed" on BSC
I have problem on get quote always return "Gas estimation failed" ... I use this link reply response always estimate gas estimation failed, ......
Read more >
hardhat cannot estimate gas; transaction may fail or ... - You.com
npx hardhat run ./scripts/sample-script.js --network optimism; See the following error: Error: cannot estimate ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found