简体   繁体   English

web3py maxPriorityFeePerGas 不起作用?

[英]web3py maxPriorityFeePerGas doesn't work?

I'm trying to setup gas price properly (BSC blockchain) using maxPriorityFeePerGas, maxFeePerGas but I always receive an error:我正在尝试使用 maxPriorityFeePerGas、maxFeePerGas 正确设置汽油价格(BSC 区块链),但我总是收到错误消息:

ValueError: {'code': -32601, 'message': 'the method eth_maxPriorityFeePerGas does not exist/is not available'}

It works for me only with gasPrice setup.它仅适用于 gasPrice 设置。 Am i doing something wrong or these methods isn't implemented in web3 python yet?我做错了什么或者这些方法还没有在 web3 python 中实现吗?

contract_tx = contract.functions.check([var1, var2, var3],[int1, int2, int3], sign_buy).buildTransaction(
        {'nonce':nonce,
         'gas': 250000,
         # 'maxPriorityFeePerGas': web3.toWei(20,'gwei'),
         # 'maxFeePerGas': web3.toWei(30,'gwei'),
         'gasPrice': web3.toWei(8,'gwei')
        }
    )
    signed_tx = web3.eth.account.signTransaction(contract_tx, pkey)
    hash = web3.eth.send_raw_transaction(signed_tx.rawTransaction)

web3 - 5.25.0 web3-5.25.0

Apparently, you're dealing with legacy transactions.显然,您正在处理遗留事务。 Documentation says: 文档说:

Gas price strategy is only supported for legacy transactions. Gas 价格策略仅支持遗留交易。 The London fork introduced maxFeePerGas and maxPriorityFeePerGas transaction parameters which should be used over gasPrice whenever possible.伦敦分叉引入了maxFeePerGasmaxPriorityFeePerGas交易参数,应尽可能在gasPrice上使用。 For Ethereum (legacy) transactions, gas price is a delicate property.对于以太坊(遗留)交易,gas 价格是一个微妙的属性。 For this reason, Web3 includes an API for configuring it.出于这个原因,Web3 包含一个 API 用于配置它。

Adding the "gasPrice": web3.eth.gas_price key-value to your buildTransaction kwargs will solve the error.将 "gasPrice": web3.eth.gas_price 键值添加到您的 buildTransaction kwargs 将解决错误。 See this .看到这个

The Web3py docs also specify the following: Web3py 文档还指定了以下内容:

Whoa there, Binance Smart Chain user.哇,币安智能链用户。 Web3,py is an Ethereum-specific library. Web3,py 是以太坊专用的库。 which now defaults to “type 2” transactions as of the London.network upgrade.自 London.network 升级以来,现在默认为“类型 2”交易。 BSC apparently does not support these newer transaction types. BSC 显然不支持这些较新的交易类型。

From issues opened, it seems BSC transactions must include gasPrice, but not type, maxFeePerGas, or maxPriorityFeePerGas.从打开的问题来看,似乎 BSC 交易必须包括 gasPrice,但不包括类型、maxFeePerGas 或 maxPriorityFeePerGas。 If you have trouble beyond that, please find an appropriate BSC forum to raise your question.如果您还有其他问题,请找到合适的 BSC 论坛提出您的问题。 https://web3py.readthedocs.io/en/v5/web3.eth.html#module-web3.eth https://web3py.readthedocs.io/en/v5/web3.eth.html#module-web3.eth

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM