Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

207
Vistas
Avoid "This gas fee has been suggested by" message in MetaMask using web3

I'm currently in the process of upgrading an Ethereum dApp (using React JS) to conform to the new EIP-1559 standard (A.K.A. the London hard fork). The app uses web3.js (v1.5.2) to initiate transactions which take on a form something like

const contract = new web3.eth.Contract(
  contractABI,
  CONTRACT_ADDRESS,
);

await contract.methods
  .deposit(recepient, amount)
  .send({ from: account, value })

We encourage users to interface with our app using MetaMask.

Despite the fact that I neither specify a gasPrice, gasLimit, nor the equivalent maxPriorityFeePerGas or maxFeePerGas specified by EIP-1559 when a transaction is sent, MetaMask still warns (on my local test environment) "localhost suggested gas fee" with "Unknown processing time" and a potentially huge fee.

On clicking "Edit" another warning message appears, to make matters worse, the values I (or I guess web3) supposedly "suggested" are not reasonable according to MetaMask's estimate.

Is there any way using web3 interfacing with MetaMask to accept MetaMask's suggested values, removing these MetaMask warnings and insuring that the fees are calculated correctly? I notice looking at https://app.uniswap.org/ that although MetaMask still shows the first "app.unswap.org suggested gas fee" warning, the txn time is correctly calculated and clicking on "Edit" does not present any further warnings. Is Uniswap's more reasonable interaction with MetaMask replicable using web3.js?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

OK, so I've figured this one out.

If maxPriorityFeePerGas and maxFeePerGas are not defined for a particular transaction, web3 will generate its own values. Disappointingly, the generated values are pretty poor and will trigger warnings in MetaMask. The solution (at the point of writing completely undocumented) is to set maxPriorityFeePerGas and maxFeePerGas to null instead of undefined. This will signal to web3 that you don't want it to pass the provider these values.

So the code should look something like:

const contract = new web3.eth.Contract(
  contractABI,
  CONTRACT_ADDRESS,
);

await contract.methods
  .deposit(recepient, amount)
  .send({ 
    from: account, 
    value, 
    maxPriorityFeePerGas: null,
    maxFeePerGas: null, 
  });

Also, ensure that you're using the latest version of web3, since EIP-1559 support was only added in v1.5.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda