ethereum / web3.py

A python interface for interacting with the Ethereum blockchain and ecosystem.
http://web3py.readthedocs.io
MIT License
5.02k stars 1.71k forks source link

unable to locate this transaction hash #783

Closed bigEvilBanana closed 6 years ago

bigEvilBanana commented 6 years ago

Version: 4.1.0 Python: 2.7/3.4/3.6 OS: osx/linux/win

What was wrong?

I'm trying to send transaction with the following code:

w3 = Web3(HTTPProvider("https://ropsten.infura.io/gDQS9CITR39Fjvn3WGMD"))
w3.eth.enable_unaudited_features()

address = "0x8e9A...."
MY_PRIVATE_KEY = '0x8ef774e77....'

transaction = {
    'to': address,
    'from': MY_ETH_ADDRESS,
    'value': 0,
    'gas': 2000000,
    'gasPrice': 234567897654321,
    'nonce': int(time.time()),
    'chainId': chainId,
    'data': web3.Web3.toHex(str(some_text))
}

signed = w3.eth.account.signTransaction(transaction, MY_PRIVATE_KEY)
hash = w3.eth.sendRawTransaction(signed.rawTransaction)
print(web3.Web3.toHex(hash))

As result I got txHash, but when I'm trying to find this transaction at etherscan I got nothing (https://ropsten.etherscan.io/tx/0x6e863430e83a22d93ae8181c54e40f309427deb8b1900bae222223d8ca8c173f).

The transaction is not sent and I can't figure out what the problem is. I suppose something wrong with gasPrice. Any suggestions? Thank you!

carver commented 6 years ago

Each transaction from an address must increment nonce starting at 0. Higher nonces will just sit as pending on the network, until they are eventually included or dropped.