Why is getTransactionReceipt() returning None (NoneType object)?

0 votes

I am using the following code:

provider = HTTPProvider('http://0.0.0.0:9945')
w3 = Web3(provider)

contract = w3.eth.contract(contract_interface['abi'], bytecode=contract_interface['bin'])

tx_hash = contract.deploy(transaction={'from': w3.eth.coinbase, 'gas': 250000})

print (tx_hash)
time.sleep(1)
tx_receipt = w3.eth.getTransactionReceipt(tx_hash)
print (tx_receipt)
contract_address = tx_receipt['contractAddress']

The tx_hash variable is getting a valid valid but tx_receipt is getting none.

The error I am getting is as follows:
contract_address = tx_receipt['contractAddress']
TypeError: 'NoneType' object is not subscriptable

w3.eth.getTransactionReceipt(tx_hash) function returns None

I dont understand why. Please help.

Jul 24, 2018 in Blockchain by digger
• 27,620 points
67 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
By looking at your code, it seems like the code "(w3.eth.getTransactionReceipt(tx_hash)" is getting executed before the block has been mined. According to the getTransactionReceipt doc http://web3py.readthedocs.io/en/latest/web3.eth.html#web3.eth.Eth.getTransactionReceipt),
getTransactionReceipt returns None when the transaction has not yet been mined. The sleep(1) is not giving enough time for the
blocks to be mined.

If you are using geth, start mining by turning on --mine or else try while w3.eth.getTransactionReceipt(tx_hash) is None
answered Jul 24, 2018 by slayer
• 29,040 points

Related Questions In Blockchain

+1 vote
1 answer
0 votes
2 answers
0 votes
1 answer

Why is it downloading the blocks when I am trying to deploy the ethereum private network?

Once you have installed the Ethereum wallet, ...READ MORE

answered May 3, 2018 in Blockchain by Shashank
• 10,330 points
21 views
0 votes
1 answer

Why is Nubits faster than Bitcoin?

Different implementation of blockchain can have different ...READ MORE

answered Jul 11, 2018 in Blockchain by digger
• 27,620 points
12 views
0 votes
1 answer
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 27,620 points
52 views
+1 vote
1 answer
0 votes
1 answer

Where is the data stored in blockchain?

The smart contract is just the business ...READ MORE

answered Jun 29, 2018 in Blockchain by slayer
• 29,040 points
64 views
0 votes
1 answer

"const is reserved" parse error.

It could be an error because of ...READ MORE

answered Jul 6, 2018 in Blockchain by slayer
• 29,040 points
65 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.