The transactions created by web3 (python) aren't reflected on the Ethereum blockchain


I’m trying to use with to send ethereum tokens from one address to another.
This returns to me a transaction ID. But it just never goes on to the blockchain when I check it. I have used high gas amount but it still doesn’t work (The transaction id isn’t present on the blockchain as per and also as per functions)

I tried a few other ways of signing the transaction but they didn’t work either.

Please help me make this work.

import web3
import time
w = web3.Web3(web3.HTTPProvider(''))

# gas example
gas_limit = 250000
gas_price = 60

transaction = {
signed_transaction = w.eth.account.signTransaction(transaction, key)
transaction_id = w.eth.sendRawTransaction(signed_transaction.rawTransaction)

print ('n{0}'.format(transaction_id.hex()))
Asked By: aste123



Your nonce is incorrect. This is not supposed to be a random value, but a scalar used to identify the number of transactions that have occurred from this account. This is used to make sure transactions are executed in the correct order they were submitted from the sender’s address. If you have a gap in your nonce, the transaction with the higher nonce won’t be executed until that gap is filled. Using time for nonce pretty much guarantees your transaction will never get mined.

You can use nonce = w.eth.getTransactionCount('from_addr') to get the correct nonce value. Note that the nonce is 0-based.

Answered By: Adam Kipnis
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.