RowinVanAmsterdam / blog--disable-site-suggested-gas-fee-in-metamask-using-web3js

A repository for my blog
1 stars 0 forks source link

Disable site suggested fee for latest web3 version #1

Open abhilashbr92 opened 1 year ago

abhilashbr92 commented 1 year ago

Hello,

I am using web3 v1.10.0 and I could disable site suggested fee on metmask confirm window. But after updating the web3 version to 4.0.3, the site suggested fee is visible again. Please let me know Is the feature to disable site suggested fee removed in latest version?

    const web3 = new Web3(window.ethereum);
    const contract = new web3.eth.Contract(erc20ABI, contractAddress);
    contract.methods
      .transfer(destinationAdrs, (depositAmt * 1000000).toString())
      .send({ from: sourceAdrs, gas: "21000", maxPriorityFeePerGas: null, maxFeePerGas: null })
      .then(function (receipt) {
        console.log(receipt);
      }).catch(function (error) {
        console.log(error);
      });

Thank you

RowinVanAmsterdam commented 1 year ago

Hey @abhilashbr92, not sure if you already fixed the issue yourself. But can you try to set maxPriorityFeePerGas and maxFeePerGas to undefined? Instead of null.

They mentioned in their documentation:

All the API level interfaces returning or accepting null in 1.x, use undefined in 4.x