Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

fillGasPrice fundamentally changed transactions, should have been a breaking change? #6801

@Quicksaver

Description

@Quicksaver

Expected behavior

Up until v4.0.3, Contract transactions would go through without explicitly estimating gas prices on the caller side; web3js did it automatically. We could do this and everything would work fine:

  const contract = provider && new provider.eth.Contract(abi, address);

Actual behavior

Since v4.1.0, this behavior changed as the default value for fillGasPrice is set as false. It becomes mandatory to do this:

  const contract = provider && new provider.eth.Contract(abi, address, {
    gasPrice: await provider.eth.getGasPrice(), // <--- this line becomes mandatory
  });

Also, the prepareTransactionForSigning is never called with this parameter (or with fillGasLimit BTW), meaning the default Contract object instances cannot be given those flags without a custom transactionBuilder method in the web3Context of the caller, which is overkill just to set simple boolean flags.

In practice, unless I am missing something obvious (I could be, but definitely need someone to point it out and I would greatly appreciate it!), it seems we are stuck to manually estimating gas for each contract/transaction beforehand.

E.g. every single transaction, processed via metamask on either BNB Mainnet or Testnet, for which we do not estimate gas price explicitly, fails, as it defaults to 2,5 GWEI which is below the minimum necessary on both networks for txs to go through.

This was buried in the changelog in the line:

sendTransaction will have gas filled by default using method estimateGas unless transaction builder options.fillGas is false

Please note that

  • there is no fillGas option anywhere;
  • fillGasPrice and fillGasLimit are not easily set without a custom transactionBuilder in the Contract's web3Context;
  • and this actually seems to be a lie because the default value for the option is false and not true.

As mentioned, if I am wrong I definitely need clarification here as documentation and examples are scarce around this.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions