MetaMask Gas Estimate – Fixing MetaMask Gas Price Estimate on Ropsten

metamaskropstentruffle

Update: For some reason, just redeploying with truffle migrate --network ropsten --compile-all fixed the issue, and MetaMask now suggests Gwei.


After deleting build/contracts dir, I deployed my Smart Contract to Ropsten with:

truffle migrate --network ropsten --reset --compile-all

and the following in truffle.js config:

networks: {
  [...],
  ropsten: {
    provider: new HDWalletProvider(mnemonic, "https://ropsten.infura.io/"+infura_apikey),
    network_id: 3,
    gas: 4500000, // Current Ropsten gas limit. See https://ropsten.etherscan.io/block/3141628
    gasPrice: 1100000000 // 1.1 GWei - based on the lower end of current txs getting into blocks currently on Ropsten.
  }
}
solc: {
  optimizer: {
    enabled: false,
    runs: 500
  }
}

Everything works fine on my local Ganache. But deployed to Ropsten, MetaMask always prefills transactions with Gas Price: 0

Zero gas price

How can I fix the gas price estimation for MetaMask?

PS. Transaction works fine if I manually set the gas price in the MetaMask dialog. But it's a really ugly user experience.

Best Answer

I believe the error message you're getting is probably coming from Infura (the node MetaMask connects to by default). So, there's no way to fix this for the final user in order that the error comes from a 3rd party.

  • If you don't care about migrating from the interface, you can run your own node and use Mist or geth. Or you could sign transactions offline and broadcast them via etherscan.io. Other than those options.
  • If at a certain point you discover an Infura node that works OK and doesn't give you that error, you can always point to it in order to don't get the error repeated.

Otherways, you'll be obligated to change manually the Gas Price manually, which in most cases isn't that bad trust me. Lots of people have lost many money by extremely high Gas Prices paid.

Hope it helps.

Related Topic