简体   繁体   English

ValueError:不支持方法 eth_maxPriorityFeePerGas,带有 ganache 的 web3.py

[英]ValueError: Method eth_maxPriorityFeePerGas not supported, web3.py with ganache

I'm running the following code with web3.py :我正在使用web3.py运行以下代码:

transaction = SimpleStorage.constructor().buildTransaction(
    {"chainId": chain_id, "from": my_address, "nonce": nonce}
)

And I am running into the following error:我遇到了以下错误:

Traceback (most recent call last):
  File "/Users/patrick/code/web3_py_simple_storage/deploy.py", line 64, in <module>
    transaction = SimpleStorage.constructor().buildTransaction(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/eth_utils/decorators.py", line 18, in _wrapper
    return self.method(obj, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/web3/contract.py", line 684, in buildTransaction
    return fill_transaction_defaults(self.web3, built_transaction)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/web3/_utils/transactions.py", line 121, in fill_transaction_defaults
    default_val = default_getter(web3, transaction)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/web3/_utils/transactions.py", line 71, in <lambda>
    web3.eth.max_priority_fee + (2 * web3.eth.get_block('latest')['baseFeePerGas'])
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/web3/eth.py", line 549, in max_priority_fee
    return self._max_priority_fee()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/web3/module.py", line 57, in caller
    result = w3.manager.request_blocking(method_str,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/web3/manager.py", line 198, in request_blocking
    return self.formatted_response(response,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/web3/manager.py", line 171, in formatted_response
    raise ValueError(response["error"])
ValueError: {'message': 'Method eth_maxPriorityFeePerGas not supported.', 'code': -32000, 'data': {'stack': 'Error: Method eth_maxPriorityFeePerGas not supported.\n    at GethApiDouble.handleRequest (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/lib/subproviders/geth_api_double.js:70:16)\n    at next (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:136:18)\n    at GethDefaults.handleRequest (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/lib/subproviders/gethdefaults.js:15:12)\n    at next (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:136:18)\n    at SubscriptionSubprovider.FilterSubprovider.handleRequest (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/subproviders/filters.js:89:7)\n    at SubscriptionSubprovider.handleRequest (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/subproviders/subscriptions.js:137:49)\n    at next (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:136:18)\n    at DelayedBlockFilter.handleRequest (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/lib/subproviders/delayedblockfilter.js:31:3)\n    at next (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:136:18)\n    at RequestFunnel.handleRequest (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/lib/subproviders/requestfunnel.js:32:12)\n    at next (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:136:18)\n    at Web3ProviderEngine._handleAsync (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:123:3)\n    at Timeout._onTimeout (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:107:12)\n    at listOnTimeout (internal/timers.js:531:17)\n    at processTimers (internal/timers.js:475:7)', 'name': 'Error'}}

How do I fix this?我该如何解决?

This is an issue from a new edition of web3.py.这是来自新版 web3.py 的问题。

You need to add gasPrice to your transaction, like so:您需要将gasPrice添加到您的交易中,如下所示:

transaction = SimpleStorage.constructor().buildTransaction(
    {"chainId": chain_id, "gasPrice": w3.eth.gas_price, "from": my_address, "nonce": nonce}
)

This is due to EIP1559 changing, and web3.py updating for the change.这是由于 EIP1559 更改,以及 web3.py 更新的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我尝试使用 Ganache 运行 Web3py 时,为什么会收到错误“Method eth_maxPriorityFeePerGas 不支持”? - Why do I get the error "Method eth_maxPriorityFeePerGas not supported" when I try to run Web3py with Ganache? 在 ganache 上调用函数时出现 Web3.py abi keyerror - Web3.py abi keyerror while calling a function on ganache web3.py - 发送签名交易问题(不支持交易类型) - web3.py - sending signed transaction issue (transaction type not supported) Web3.py:使用挂起过滤器时出现 ValueError - Web3.py: ValueError when using pending filter 如何使用短语和 Web3.py 连接到已经创建的 ETH 钱包? - How to connect to already created ETH wallet using phrase and Web3.py? 如何使用 web3.py 在给定的 ETH 地址获取特定的代币余额 - How to get the specific token balance available at a give ETH address using web3.py web3py maxPriorityFeePerGas 不起作用? - web3py maxPriorityFeePerGas doesn't work? UserWarning:eth_maxPriorityFeePerGas 方法存在问题。 使用 eth_feeHistory 计算 - UserWarning: There was an issue with the method eth_maxPriorityFeePerGas. Calculating using eth_feeHistory 使用 web3.py 时出现 ContractLogicError - ContractLogicError while using web3.py TypeError:'type' object 不可订阅 web3.py - TypeError: 'type' object is not subscriptable web3.py
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM