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

Final 1559 major updates #2066

Closed
fselmo opened this issue Jul 8, 2021 · 3 comments
Closed

Final 1559 major updates #2066

fselmo opened this issue Jul 8, 2021 · 3 comments
Assignees

Comments

@fselmo
Copy link
Collaborator

fselmo commented Jul 8, 2021

What was wrong?

  • Missing default values for maxFeePerGas and maxPriorityFeePerGas in /web3/_utils/transactions.py
  • Our unit / core tests do not test for the new EIP-1559 params maxFeePerGas and maxPriorityFeePerGas
  • Our docs still use gasPrice values in the examples / code samples rather than the new maxFeePerGas and maxPriorityFeePerGas fields

How can it be fixed?

Once eth-tester has EIP-1559 support:

  • Add agreed-upon default values for maxFeePerGas and maxPriorityFeePerGas in /web3/_utils/transactions.py
  • Update the tests that rely on eth-tester and our docs to test for / use the new params maxFeePerGas and maxPriorityFeePerGas wherever gasPrice is currently being used. We should make sure to still include some tests with the gasPrice param, wherever appropriate, to ensure our support for legacy transactions.

Note: This is dependent on eth-tester support for EIP-1559 / london hard fork

@SamarthPardhi
Copy link

I am using Infura network and currently sending my transactions in web3.py like this:

tx = {
    'nonce': nonce,
    'to': toAddr,
    'value': int(value),
    'gas': gas, #21000
    'gasPrice': web3.toWei(gasPrice, 'gwei')
}
signed_tx = web3.eth.account.sign_transaction(tx, privKey) 
tx_hash = web3.eth.sendRawTransaction(signed_tx.rawTransaction)

In order to make EIP-1559 styled transaction I modified the tx as:

tx = {
    'nonce': nonce,
    'to': toAddr,
    'value': int(value),
    'gas': gas, #21000,
    'maxFeePerGas': web3.toWei(maxFee, 'gwei'),
    'maxPriorityFeePerGas': web3.toWei(PriorityFee, 'gwei')
}

But, now I'm getting error that gasPrice is not provided. I am using web3's version: 5.23.1

Can you please help me to how to make EIP-1559 transactions in web3.py correctly.

@fselmo
Copy link
Collaborator Author

fselmo commented Sep 15, 2021

@SamarthPardhi, this is the line that's important here:

signed_tx = web3.eth.account.sign_transaction(tx, privKey) 

You need to add {type: '0x2'} as a param to your transaction for signing at the moment. There is a PR out for eth-account to make this implicit decision for the user but at the moment you need to be explicit about the type of transaction you are sending. 1559 dynamic fee transactions have type = 2. I hope this helps.

Edit: The explicit type is no longer necessary. Updating here for a better history.

@fselmo
Copy link
Collaborator Author

fselmo commented Dec 17, 2021

Closed by #2205

@fselmo fselmo closed this as completed Dec 17, 2021
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

No branches or pull requests

2 participants