Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code: -32602 message: "Invalid transaction envelope type: specified type 0x0 but including maxFeePerGas and maxPriorityFeePerGas requires type: 0x2 #11824

Closed
VexyCats opened this issue Aug 12, 2021 · 28 comments
Labels
EIP-1559 Tasks required to complete 1559 support

Comments

@VexyCats
Copy link

Describe the bug

Trying to send a simple ETH transfer from a dapp - dapp is suggesting a gas price based on pre-EIP-1559, yet metamask 10.0.0 is work EIP-1559

Steps to reproduce (REQUIRED)
Steps to reproduce the behavior, libraries used with version number, and/or any setup information to easily reproduce:

Send an eth transaction with a gas limit of say "30000", normal web3 sendTransaction with a value.

Expected behavior
To let the user send X amount of ETH to XYZ address.

Screenshots
If applicable, add screenshots to help explain your problem.

Browser details (please complete the following information):
Metamask 10.0.0

Additional context (Error Messages, etc.)

RPC Error: Invalid transaction envelope type: specified type "0x0" but including maxFeePerGas and maxPriorityFeePerGas requires type: "0x2" code: -32602

@lydianblues
Copy link

Same thing here, on both the Chrome and Firefox browser extensions:

MetaMask - RPC Error: Invalid transaction envelope type: specified type "0x0" but including maxFeePerGas and maxPriorityFeePerGas requires type: "0x2" {code: -32602, message: "Invalid transaction envelope type: specified type …Gas and maxPriorityFeePerGas requires type: "0x2""}

@iObedson
Copy link

I'm having similar issue!

Invalid transaction envelope type: specified type "0x0" but including maxFeePerGas and maxPriorityFeePerGas requires type: "0x2"

Metamask error

@citizen-lab
Copy link

I also had this issue and would like to know how to resolve it. I missed a mint today, and would like to not miss any more in the future because of this error.

@danjm
Copy link
Contributor

danjm commented Aug 13, 2021

@VexyCats @lydianblues @iObedson @citizen-lab Would any of you be able to share the dapps you are intereacting with when this happens?

If you prefer, you can share privately by creating an issue with our customer support: https://metamask.zendesk.com/hc/en-us/requests/new

If we can investigate one of these dapps, we will be able to diagnose the issue

@danjm
Copy link
Contributor

danjm commented Aug 13, 2021

Send an eth transaction with a gas limit of say "30000", normal web3 sendTransaction with a value.

Oh, maybe this implies that it can happen with any dapp that does that...

@danjm
Copy link
Contributor

danjm commented Aug 13, 2021

If you are experiencing this during local development, can you share the transaction parameters of the transaction that is causing this issue?

@hariesnurikhwan
Copy link

@danjm this happened for my production dapp as well, but it seems, this doesn't happen to everyone because some of our users were able interact with our contract using eip 1559 tx.

@danjm
Copy link
Contributor

danjm commented Aug 13, 2021

@hariesnurikhwan Which dapp is that?

@iObedson
Copy link

iObedson commented Aug 14, 2021

Ok, my case was a clone of Dapp University decentragram https://github.com/dappuniversity/decentragram

@nijuusanji
Copy link

I uninstalled metamask version 10.0.1 then install metamask version 9.8.4 and it works! (chrome and firefox)

@danjm
Copy link
Contributor

danjm commented Aug 14, 2021

@iObedson Thanks for sharing the dapp you are using.

I am pretty sure what is happening here is that web3.js is automatically adding a type property to transactions that don't specifiy a type or gas fee parameters. This defaults to type 0x0. (web3/web3.js@c474f8f#diff-9050e060908a6957eb4e25bb2f4b8930f5097e55e846e0e8194ff5fa3a3440a4R835)

Then metamask is adding eip1559 gas fee properties, but these require type 0x2. https://github.com/MetaMask/metamask-extension/blob/develop/app/scripts/controllers/transactions/index.js#L408-L449

MetaMask should respect a type property if no other gas fee parameters are provided, and autoadd properties that align with a type. A fix to this will be made very soon.

In the meantime, dapp developers looking to work around this issue can try the following if developing for EIP1559 compatible networks (mainnet, rinkeby, ropsten, goerli): add type: '0x2' to the parameters you pass to send or sendTransaction. If you are developing a dapp that you aim to be compatible on both EIP1559 networks AND on non EIP1559 networks, you will need to set the type depending on whether the current network is EIP1559 compatible or not. I can comment more on that if someone needs help.

However, once MetaMask makes the fix I mention above, the error should go away. Note that because of the way web3.js currently works, your users might default to using non-EIP1559 gas properties (i.e. gasPrice) even when on an EIP-1559 network,

@sohaibgv
Copy link

@danjm How does this work for methods that are not transactions?
I'm getting the same errors for contract interactions such as unstake and stake. But the contracts only allow one parameter (amount) to be sent along. Passing type wouldn't really work.
I've been looking into workarounds like using sendTransaction to call a contract method but unsure of what this would work. Found the following but would like some recommendations on the best work around.
https://ethereum.stackexchange.com/questions/8736/how-to-call-my-contracts-function-using-sendtransaction

@sohaibgv
Copy link

Question seems to have been solved by myself. You can just simply pass it into the .send() parameter when calling the function like this:
(React class based)
this.state.tokenFarm.methods.unstake(this.state.stakingBalance).send({ from: this.state.account, type:'0x2' })
Hopefully we can all work around this issue for now.

@hariesnurikhwan
Copy link

@danjm How do I make my dapp compatible for both?

@danjm
Copy link
Contributor

danjm commented Aug 14, 2021

@hariesnurikhwan You need detect whether the current network is EIP1559 compatible or not. To do so, you can make a call to get the latest block, and check if the block data has a baseFeePerGas property. You should be able to use this to get the block: https://web3js.readthedocs.io/en/v1.4.0/web3-eth.html#getblock

If it has a baseFeePerGas property, you know it is an EIP1559 network and set the type to 0x2, and if it does not, you can leave the type empty

@GregTheGreek
Copy link

We (web3js) are getting a patch put together. This was an oversight on our end due to complicated legacy code and tests. Sorry for any inconveniences.

To mitigate this in the future we’ve been working on a ground up rewrite natively in TypeScript and it’s nearing a beta release. Hopefully in the future it will be much more maintainable.

@iObedson
Copy link

iObedson commented Aug 14, 2021

I uninstalled metamask version 10.0.1 then install metamask version 9.8.4 and it works! (chrome and firefox)

yes! for none techie this actually solve the problem. Thanks @nijuusanj

@GregTheGreek
Copy link

GregTheGreek commented Aug 15, 2021

👋

We've published a new release can you please test it out.

We've ran it across multiple repos and the error reported above. It seems to have been fixed.

https://github.com/ChainSafe/web3.js/releases/tag/v1.5.2-rc.0

Cc @danjm

@spacesailor24
Copy link

spacesailor24 commented Aug 15, 2021

Ok, my case was a clone of Dapp University decentragram https://github.com/dappuniversity/decentragram

@iObedson I've tested this Dapp using web3@1.5.2-rc.0 and no longer received the error

@danjm
Copy link
Contributor

danjm commented Aug 16, 2021

thanks @GregTheGreek!

@darkwing darkwing added the EIP-1559 Tasks required to complete 1559 support label Aug 19, 2021
@JF0001
Copy link

JF0001 commented Aug 20, 2021

Is passing the "type: '0x2'" parameter when calling the send function the recommended way to fix this issue (seems to work this way)? Once MetaMask issues a fix,I can still pass the type parameter, correct? Also, what was fixed in the web3 release referenced above? I thought that the issue was in MetaMask and not web3. Should I upgrade web3 to the latest version above in order to make sure to not encounter this problem in the future? Thank you. J

@tylerimpey
Copy link

tylerimpey commented Aug 20, 2021

Also still having this issue, tried downloading the recommended version of web3 and didn't fix. Passing 0x2 as the type seems to be the only way but then I receive an "Unknown processing time" notification from MetaMask, where it seems to think the transaction will take an extended amount of time.

Edit: For context, I'm calling estimateGas which is giving me roughly what I'd expect. The transactionOptions are:

{
    from: wallet.address, 
    value: price, 
    gasLimit: gasEstimate,
    type: "0x2",
}

And the subsequent send is called via:

await contract.methods.mint().send(options)

@mustafamertkisa
Copy link

You can try this:

metamask settings -> advanced -> reset account

@mustafamertkisa
Copy link

Also still having this issue, tried downloading the recommended version of web3 and didn't fix. Passing 0x2 as the type seems to be the only way but then I receive an "Unknown processing time" notification from MetaMask, where it seems to think the transaction will take an extended amount of time.

Edit: For context, I'm calling estimateGas which is giving me roughly what I'd expect. The transactionOptions are:

{
    from: wallet.address, 
    value: price, 
    gasLimit: gasEstimate,
    type: "0x2",
}

And the subsequent send is called via:

await contract.methods.mint().send(options)

I just added type: "0x2" and my contract worked

@cbrzn
Copy link

cbrzn commented Mar 7, 2023

hey it seems that you support tx type 0x2 but not 0x02, hence, not making you compatible with ethers-rs library - this issue is related foundry-rs/foundry#3890

fwiw, I think it would make sense if you also support 0x02 as transaction type since that's how the EIP defines it (iiuc) https://eips.ethereum.org/EIPS/eip-1559#abstract

@GregTheGreek
Copy link

@cbrzn Node and v8 will interpret both hex decimals as equivalent, so ya that should probably not be a strict check.

example:

Welcome to Node.js v16.10.0.
Type ".help" for more information.
> 0x02
2
> 0x2
2

@cbrzn
Copy link

cbrzn commented Mar 9, 2023

@GregTheGreek i might be totally out of place here (and sorry if I am, I haven't touched this codebase) but I think that's not the case because here the type is defined as string "0x2" and is being compared with another string here? In my case that second string being 0x02

@danjm
Copy link
Contributor

danjm commented Mar 9, 2023

The initially raised issue was resolved in 2021, but the comment from 2 days describes a bug that was never sovled. I have opened a new ticket for the latter #18076

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EIP-1559 Tasks required to complete 1559 support
Projects
None yet
Development

No branches or pull requests