python - 以太坊 ropsten 网络中的交易
问题描述
我正在尝试在以太坊 ropsten 测试网中进行交易,并且我从 ropsten ethereum 水龙头接收以太币,但是当我尝试发送交易时会引发此错误:ValueError: {'code': -32000, 'message': 'gas 资金不足 * 价格 + 价值'}。我能怎么做?
这是我的代码:
from web3 import Web3
def sendTransaction(message):
w3 =
Web3(Web3.HTTPProvider('')) #ropsten provider link
address = '' #address of wallet
privateKey = '' #privatekey
nonce = w3.eth.getTransactionCount(address)
gasPrice = w3.eth.gasPrice
value = w3.toWei(0, 'ether')
signedTx = w3.eth.account.signTransaction(dict(
nonce=nonce,
gasPrice=gasPrice,
gas=100000,
to='0x0000000000000000000000000000000000000000',
value=value,
data=message.encode('utf-8')
), privateKey)
tx = w3.eth.sendRawTransaction(signedTx.rawTransaction)
txId = w3.toHex(tx)
return txId
拜托,有人可以解释我哪里错了吗?
解决方案
推荐阅读
- android - 使用 MpAndroidChart 在饼图中显示大数字(双值)
- javascript - 在 JavaScript 中返回数组的值
- django - React 调用 Django API CSRF
- java - 如何从 Firebase 数据库中删除消息?
- shell - 如何把这个 Vim 命令变成一个函数?
- google-analytics - 如何在 Google Analytics 中均匀匹配事件点击和目标?
- javascript - 无法使用 IE11 动态填充下拉框
- postgresql - 跨表维护复杂的逻辑完整性
- sql - 预获取时间戳差异
- unit-testing - 如何在 .NET Core 2.1 的测试项目中加载配置数据?