Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing estimateGas error message in Hardhat node #1731

Open
fvictorio opened this issue Jul 26, 2021 · 8 comments
Open

Confusing estimateGas error message in Hardhat node #1731

fvictorio opened this issue Jul 26, 2021 · 8 comments
Labels
status:ready This issue is ready to be worked on type:improvement

Comments

@fvictorio
Copy link
Member

fvictorio commented Jul 26, 2021

A user got this output in their node:

image

I don't have reproduction steps, although it can probably be simulated locally by hardcoding some throw somewhere. The point is that a message like that is very confusing and we should either not show anything at all or show something better.

My guess of how to reproduce this:

  1. Check the part of the code that throws when an unrecognized error happens
  2. Hardcode that to make it always throw
  3. Start an hh node and send an eth_estimateGas

EDIT: I'm pretty sure that most of the time this happens because of #3474; check that issue for an explanation and a workaround. This issue is still valid though: we should show a better error message when an unhandled error is thrown.

EDIT 2: we should improve this for all JSON-RPC methods, not just eth_estimateGas. See for example #1311.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2022

This issue was marked as stale because it didn't have any activity in the last 30 days. If you think it's still relevant, please leave a comment indicating so. Otherwise, it will be closed in 7 days.

@github-actions github-actions bot added the Stale label Aug 5, 2022
@fvictorio fvictorio added not-stale and removed Stale labels Aug 8, 2022
@degoev
Copy link

degoev commented Aug 10, 2022

have this issue too

@penguin4238
Copy link

have this issue too with apple m1 and node v18.4.0, hardhat 2.10.2

@gapon2401
Copy link

I have the same issue. Hardhat 2.11.0
I'm trying to test smartcontract locally.

My steps to reproduce:

  1. Fork the mainnet:

A part of hardhat.config.ts

networks: {
    hardhat: {
      allowUnlimitedContractSize: true,
      forking: {
        url: "https://eth-mainnet.g.alchemy.com/v2/<ALCHEMY_KEY>",
      }
    },
    localhost: {
      allowUnlimitedContractSize: true,
      chainId: 31337,
      accounts: [`PRIVATE_KEY1`, `PRIVATE_KEY2`],
    },
}
  1. Auth in metamask, connect to network localhost:8545 with chainId 31337
  2. Add hardhat account in metamask with PRIVATE_KEY1
  3. Deploy smartcontract
  4. Trying to send eth to smartcontract in metamask. Button, which starts the transaction, is inactive

Here, what I have in console:

SharedScreenshot

@victorshevtsov
Copy link

I confirm. I'm facing the same issue.
Absolutely reproducible.

@victorshevtsov
Copy link

It looks like the issue is in MetaMask browser extension.

It works just fine with MetaMask for Android.
All the transactions to hardhat node goes well when performed from mobile wallet but not from a browser extension.

I tried Chrome and FireFox extensions.

@victorshevtsov
Copy link

Finally I got it!
It took almost whole day to figure out what is the cause.

The default chainId of Hardhat node is 31337 and this causes the issue.
I changed it to 1337 and everything works now.

/// hardhat.config.js:

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.17",
  networks: {
    hardhat: {
      chainId: 1337, // default is 31337
    }
  }
};

I'm sure the root of the problem is out there.
I hope somebody will figure it out and get it fixed eventually.

@nfts2me
Copy link

nfts2me commented Nov 16, 2022

Finally I got it! It took almost whole day to figure out what is the cause.

The default chainId of Hardhat node is 31337 and this causes the issue. I changed it to 1337 and everything works now.

/// hardhat.config.js:

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.17",
  networks: {
    hardhat: {
      chainId: 1337, // default is 31337
    }
  }
};

I'm sure the root of the problem is out there. I hope somebody will figure it out and get it fixed eventually.

As described here:
#3089 (comment)
I'm getting this error as well.
But changing the chainId didn't fix the issue.

May it be related to this?
trufflesuite/ganache#3332

@fvictorio fvictorio changed the title estimateGas error message in Hardhat node Confusing estimateGas error message in Hardhat node Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on type:improvement
Projects
Status: No status
Development

No branches or pull requests

6 participants