0

I am using following code to perform transaction

web3 = Web3(HTTPProvider('https://ropsten.infura.io/{}'.format('XXXXXXXXXXXXXXXXX')))
print('https://ropsten.infura.io/{}'.format('XXXXXXXXXXXXXXXXXXX'))


address = 'xxxxxx'
address2 = 'xxxxx12'
key = 'xxx'
key2 = 'xxxx12'
send =  web3.toChecksumAddress(address)
print(send)
amount = web3.toWei(1, "ether")
print(amount)
balance = web3.eth.getBalance(address)
print(balance)
value = web3.fromWei(balance, 'ether')
print(value)
nonce = web3.eth.getTransactionCount('xxxxxx')
print(nonce)
gas_limit = 250000
gas_price = 60

transaction = {
    'to':address2,
    'from':address,
    'value':int(value*(10**18)),
    'gas':gas_limit,
    'gasPrice':int(gas_price*(10**9)),
    'chainId':1,
    'nonce':0
    }
signed_transaction = web3.eth.account.signTransaction(transaction, key)
print(signed_transaction.rawTransaction.hex())
transaction_id = web3.eth.sendRawTransaction(signed_transaction.rawTransaction)

it is generating following error:

Traceback (most recent call last):
  File "/home/softmac/eth_python/send_transaction.py", line 48, in <module>
    print(web3.eth.sendRawTransaction(signed_transaction.rawTransaction))
  File "/usr/local/lib/python3.6/dist-packages/web3/eth.py", line 274, in sendRawTransaction
    [raw_transaction],
  File "/usr/local/lib/python3.6/dist-packages/web3/manager.py", line 112, in request_blocking
    raise ValueError(response["error"])
ValueError: {'code': -32000, 'message': 'invalid sender'}

I have generate private key with:

acct1 = Account.create(name)

print(acct1.privateKey.hex())
print(acct1.address)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.