首页 > 解决方案 > 以太坊 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

拜托,有人可以解释我哪里错了吗?

标签: pythondjangoblockchain

解决方案


推荐阅读