Skip to content

[Bug]: fw: incorrect gas estimation on BSC when gasPrice is not explicitly supplied by the website #20797

@Snugface

Description

@Snugface

Describe the bug

This is a duplicate of #20699 , as that one has been open for a week and is yet to receive any acknowledgment from the maintainers. And I am wondering if starting three exact same issues in a row, as some people are doing here, is the right answer to that.

MetaMask incorrectly estimates gas settings on BSC when no gas price is explicitly supplied by the website.
Likely the bug is only specific to BSC, though I haven't tried reproducing it on other chains.

Steps to reproduce

  1. Initiate transaction with a contract on BSC using web3.js without explicitly supplying any gas settings, like so:
    contract.methods.function(args).send({ from: address });
  2. Review gas settings automatically picked by Metamask, and observe that they are falsely reported as "suggested by site", while also being too low for the tx to go through
2. Screenshots

MM gas bug bad1 Screenshot from 2023-09-02 14-43-20
MM gas bug bad2 Screenshot from 2023-09-02 15-14-43

  1. Send transaction. It will fail with "transaction undepriced" error
  2. Now, to avoid this bug one must manually supply gasPrice, for example: contract.methods.function(args).send({ from: address, gasPrice: '3000000000' });
  3. Review gas settings again. Same contract, same function, same arguments. Same report from Metamask, that gas settings are supplied by the site. But this time it is true, and those gas settings are adequate
5. Screenshots

MM gas bug good1 Screenshot from 2023-09-02 15-35-27
MM gas bug good2 Screenshot from 2023-09-02 15-34-53

  1. Send transaction. Transaction succeeds

Error messages or log output

MetaMask - RPC Error: [ethjs-query] while formatting outputs from RPC '{"value":
{"code":-32603,
"data":{
"code":-32000,
"message":"transaction underpriced"
}}}'

Version

10.34.3

Build type

None

Browser

Chrome, Firefox

Operating system

Windows, Linux

Hardware wallet

No response

Additional context

web3.js version 1.6.1
RPC in use: https://bsc-dataseed2.binance.org:443 on website; https://bsc-dataseed1.binance.org:443 in wallet. Likely the same behavior is present on others, but I tested with these.
Same behavior is observed with payable and non-payable contract functions. Behavior only first appeared about 3-5 days back. So far every user who reported this behavior is a Metamask user.
No changes were made to the website codebase recently(for many weeks). So the bug is being caused either by updates in Metamask or in BSC nodes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions