使用 w3.eth.contract() 部署智能合约时出错:“不支持方法 eth_sendTransaction”

问题描述

我正在使用 Web3.py 和一个许可的 Hyperledger Besu 网络。

尝试使用 w3.eth.contract(...) 方法将智能合约部署到网络中时,出现以下错误

ValueError: {'code': -32604,'message': 'The method eth_sendTransaction is not supported. Use eth_sendRawTransaction to send a signed transaction to Besu.'}

我想在执行 w3.eth.contract(...) 时会调用 eth_sendTransaction。有没有其他方式可以部署合约而不会出现这个问题?

解决方法

您可能会使用 Infura 节点或类似工具。

You need to sign the transaction locally with Web3.py and have your app to manage the private key for you

,

您需要在发送前签署交易,更多细节:https://web3py.readthedocs.io/en/stable/web3.eth.account.html#sign-a-transaction

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...