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

If network supports EIP-1559, then we cannot send a legacy transaction #4258

Closed
floatcoder opened this issue Aug 20, 2021 · 5 comments · Fixed by #4277
Closed

If network supports EIP-1559, then we cannot send a legacy transaction #4258

floatcoder opened this issue Aug 20, 2021 · 5 comments · Fixed by #4277
Assignees

Comments

@floatcoder
Copy link

floatcoder commented Aug 20, 2021

Expected behavior

I would expect to be able to specify a legacy tx.type (i.e. "0x0" ) and allow for the gasPrice to be auto-filled. The motivation for this is that some hardware wallets do not yet support EIP1559 transactions, while the network provider will.

Actual behavior

Instead the maxFeePerGas and maxPriorityFeePerGas are set causing a transaction envelope rejection. This I imagine is due to the difference between web3-core-method _handleTxPricing and web3-eth-accounts _handleTxPricing. web3-eth-accounts checks the tx.type while web3-core-method does not.

Note that this is the reverse of the issue mentioned in MetaMask/metamask-extension#11824 where if we intend to do a legacy transaction, the gasPrice gets overwritten.

Steps to reproduce the behavior

  1. Create a const ethContract = new web3.eth.Contract(...)
  2. Send a transaction via the contract methods ethContract.methods["approve"].send({ type: "0x0" })

Logs

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

Environment

web3 1.5.2

@floatcoder
Copy link
Author

floatcoder commented Aug 20, 2021

Temporary fix for this if anyone experiences this is:

  1. Downgrade to web3 1.5.1
  2. Ensure you always set the type to 0x2 if EIP1559 is supported.
  3. If EIP1559 is not supported, you can then set the type to 0x0 and it'll work as expected.

Note that if you try to do a legacy transaction 0x0 when EIP1559 is supported this still breaks on MetaMask's side due to MetaMask/metamask-extension#11824

@melvinmcrn
Copy link

melvinmcrn commented Aug 29, 2021

@floatcoder I've tried what you have suggested and it's working for me (for both hot wallet and hardware wallet connecting via MetaMask). However, there is an error log in my console with a message as Invalid transaction envelope type: specified type \"0x02\" but including maxFeePerGas and maxPriorityFeePerGas requires type: \"0x2\" for the hot wallet case.

ps. I haven't really tried confirming the tx in MetaMask but the MetaMask UI doesn't show any error nor reverted.
ps2. I have tried with web3 1.5.0 and it seem to be working without any error. Are there any known problem with the v1.5.0?

@Pasha8914
Copy link

@rstormsf
Copy link

rstormsf commented Sep 7, 2021

WTF???? I still WANT to send a LEGACY transaction EVEN though it DOES support EIP.
Terrible decision making policy at web3. We have MULTIPLE apps with customers who doesn't WANT to send EIP tx.

spacesailor24 added a commit that referenced this issue Sep 9, 2021
* Add tx.type check to _handleTxPricing

* Add fix to CHAGELOG

* Add test for issue

* Fix typo
@spacesailor24 spacesailor24 reopened this Sep 9, 2021
@spacesailor24
Copy link
Contributor

v1.5.3-rc.0 has been released to NPM, please test to verify it solves encountered issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants