Coder Social home page Coder Social logo

Comments (7)

mconnelly8 avatar mconnelly8 commented on July 3, 2024

Thanks @umbecanessa. The team will review this soon and get back with you.

from web3.js.

Cam-B avatar Cam-B commented on July 3, 2024

similar issue here. The method mentioned by OP doesn't seem to let Metamask handle gas dynamically.

In my case the following example seems to set the correct gas fee, but Metamask shows the transaction as failed, even though the transaction was actually successful. So I'd prefer to just let Metamask handle gas completely.

      const gasEstimate = await erc20Contract.methods.approve(contractAddress, maxAllowance).estimateGas({ from: account });
      const gasPrice = await web3.eth.getGasPrice();

      const result = await erc20Contract.methods.approve(contractAddress, maxAllowance).send({
        from: account,
        gas: gasEstimate,
        gasPrice: gasPrice 

If we do this and then set "market" within Metamask gas settings, the transaction doesn't show as failed.

from web3.js.

luu-alex avatar luu-alex commented on July 3, 2024

Hey there, this is something we definitely can fix. Will probably be added as a flag to allow metamask to make suggestions. What methods were u using?

from web3.js.

Cam-B avatar Cam-B commented on July 3, 2024

Here's a very basic example:

import React from 'react';
import Web3 from 'web3';

const SimpleTransaction = () => {

    const sendTransaction = async () => {
        const web3 = new Web3(window.ethereum);
        await window.ethereum.request({ method: 'eth_requestAccounts' });
        const fromAccount = (await web3.eth.getAccounts())[0];

        const transactionParameters = {
            to: '0x.....',
            from: fromAccount,
            value: web3.utils.toWei('0.05', 'ether'),
            maxPriorityFeePerGas: undefined,
            maxFeePerGas: undefined
        };

        web3.eth.sendTransaction(transactionParameters);
    };

    return (
        <div className="flex flex-col items-center">
            <h1>Send Simple Transaction</h1>
            <button onClick={sendTransaction}>
                Send Transaction
            </button>
        </div>
    );
};

export default SimpleTransaction;

This is a snapshot of Metamask showing wrong gas fee instead of using "market" suggested gas:

metagas

from web3.js.

jdevcs avatar jdevcs commented on July 3, 2024

public sendTransaction<ReturnFormat extends DataFormat = typeof DEFAULT_RETURN_FORMAT>(

ignoreGasPricing?: boolean;

can you use above?

from web3.js.

jdevcs avatar jdevcs commented on July 3, 2024

use boolean flag to ignore gas price

from web3.js.

luu-alex avatar luu-alex commented on July 3, 2024

@umbecanessa @Cam-B Hey there sorry this needs to be clearer in the docs, but you can use the ignoreGasPricing flag

const transaction = await web3.eth.sendTransaction(
        {
          from: accounts[0],
          to: 'address',
          value: '1',
          data: '0x01',
        },
        { bytes: ETH_DATA_FORMAT.bytes, number: ETH_DATA_FORMAT.number },
        { ignoreGasPricing: true }

We'll close this issue now, but let us know if there are any other issues and we'll open it again

from web3.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.