hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

`estimateGas` error message in Hardhat node

Open fvictorio opened this issue 3 years ago • 1 comments

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

fvictorio avatar Jul 26 '21 20:07 fvictorio

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[bot] avatar Aug 05 '22 22:08 github-actions[bot]

have this issue too

degoev avatar Aug 10 '22 16:08 degoev

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

penguin4238 avatar Aug 19 '22 06:08 penguin4238

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

gapon2401 avatar Sep 06 '22 15:09 gapon2401

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

victorshevtsov avatar Oct 16 '22 14:10 victorshevtsov

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 avatar Oct 16 '22 16:10 victorshevtsov

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.

victorshevtsov avatar Oct 16 '22 19:10 victorshevtsov

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: https://github.com/NomicFoundation/hardhat/issues/3089#issuecomment-1317460141 I'm getting this error as well. But changing the chainId didn't fix the issue.

May it be related to this? https://github.com/trufflesuite/ganache/issues/3332

nfts2me avatar Nov 16 '22 18:11 nfts2me