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
• 26,740 points
1,201 views

2 answers to this question.

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,370 points
0 votes

If you want to know more about this information. 

Visit: typeerror nonetype object is not subscriptable

answered Sep 11, 2020 by pythoncourse
• 140 points

Related Questions In Blockchain

+1 vote
1 answer
0 votes
2 answers

Why is network already up to date while trying to deploy a contract on truffle?

I guess you have ganache running already ...READ MORE

answered Apr 24, 2018 in Blockchain by Shashank
• 10,400 points
4,564 views
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,400 points
653 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
• 26,740 points
644 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
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
• 26,740 points
1,000 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,370 points
1,458 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,370 points
1,596 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP