簡體   English   中英

web3py maxPriorityFeePerGas 不起作用?

[英]web3py maxPriorityFeePerGas doesn't work?

我正在嘗試使用 maxPriorityFeePerGas、maxFeePerGas 正確設置汽油價格(BSC 區塊鏈),但我總是收到錯誤消息:

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

它僅適用於 gasPrice 設置。 我做錯了什么或者這些方法還沒有在 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

顯然,您正在處理遺留事務。 文檔說:

Gas 價格策略僅支持遺留交易。 倫敦分叉引入了maxFeePerGasmaxPriorityFeePerGas交易參數,應盡可能在gasPrice上使用。 對於以太坊(遺留)交易,gas 價格是一個微妙的屬性。 出於這個原因,Web3 包含一個 API 用於配置它。

將 "gasPrice": web3.eth.gas_price 鍵值添加到您的 buildTransaction kwargs 將解決錯誤。 看到這個

Web3py 文檔還指定了以下內容:

哇,幣安智能鏈用戶。 Web3,py 是以太坊專用的庫。 自 London.network 升級以來,現在默認為“類型 2”交易。 BSC 顯然不支持這些較新的交易類型。

從打開的問題來看,似乎 BSC 交易必須包括 gasPrice,但不包括類型、maxFeePerGas 或 maxPriorityFeePerGas。 如果您還有其他問題,請找到合適的 BSC 論壇提出您的問題。 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