I am using Infura with the mainnet and web3py to interact with smart contracts and send transactions. Last week this same code worked fine, but today, trying to send the transaction for the deployment of the contract, I get this error message, on the waitForTransactionReceipt method:
File "pruebaPagos.py", line 303, in <module>
tempsensorContract, w3, nonce = construirContrato()
File "pruebaPagos.py", line 139, in construirContrato
tx_receipt = w3.eth.waitForTransactionReceipt(tx)
File "/root/Proyectos/bchain/rafa-py3/local/lib/python3.5/site-packages/web3/eth.py", line 223, in waitForTransactionReceipt
return wait_for_transaction_receipt(self.web3, transaction_hash, timeout)
File "/root/Proyectos/bchain/rafa-py3/local/lib/python3.5/site-packages/web3/utils/transactions.py", line 70, in wait_for_transaction_receipt
_timeout.sleep(poll_latency)
File "/root/Proyectos/bchain/rafa-py3/local/lib/python3.5/site-packages/web3/utils/threads.py", line 68, in sleep
self.check()
File "/root/Proyectos/bchain/rafa-py3/local/lib/python3.5/site-packages/web3/utils/threads.py", line 61, in check
raise self
web3.utils.threads.Timeout: 120 seconds
Below is my Python code that uses web3 for the deployment of the contract. I've tried to put different gas prices, but it doesn't work either. Anyone knows what is going on here? Is this an Infura problem?
contract_source_code = '''
#my solidity source code
'''
compiled_sol = compile_source(contract_source_code)
contract_interface = compiled_sol['<stdin>:tempSensor']
#connection to infura
w3 = Web3(HTTPProvider('https://mainnet.infura.io/MY-API-KEY'))
from web3.middleware import geth_poa_middleware
w3.middleware_stack.inject(geth_poa_middleware, layer=0)
count = w3.eth.getTransactionCount(account,"pending")
gasPrice = w3.toWei('3.5','gwei')
#creating the contract and its transaction for the deployment
TempSensor = w3.eth.contract(abi=contract_interface['abi'], bytecode=contract_interface['bin'])
transaction = TempSensor.constructor().buildTransaction({
'gas': w3.toHex(850000),
'gasPrice': w3.toHex(gasPrice),
'nonce': w3.toHex(count),
})
#sign the transaction and send
key = 'PRIVATE-KEY'
signed = w3.eth.account.signTransaction(transaction, key)
tx = w3.eth.sendRawTransaction(Web3.toHex(signed.rawTransaction))
print('Transaction for the deployment:')
print(Web3.toHex(tx))
tx_receipt = w3.eth.waitForTransactionReceipt(tx)
tempsensorContract = w3.eth.contract(
address = tx_receipt.contractAddress,
abi = contract_interface['abi'],
)
In etherscan.io it can't even find my transaction hash. It says:
- Sorry, we are unable to locate this Transaction Hash