1

I'm trying to deploy smartcontract on ropsten testnet through infura node in web3.py. here is my code

w3 = Web3(HTTPProvider("http://ropsten.infura.io/<*Privatekey>"))


# Instantiate and deploy contract
contract = w3.eth.contract(abi=abi, bytecode=bytecode)

# Get transaction hash from deployed contract
tx_hash = contract.deploy(transaction={'from': w3.eth.accounts[0], 'gas': 410000})

# Get tx receipt to get contract address
tx_receipt = w3.eth.getTransactionReceipt(tx_hash)
contract_address = tx_receipt['contractAddress']

when I run this code, I always ended up getting timeout error. what could be the possible reason for it. every answer is appreciable because atleast you have spent time on this question.

1

The default timeout is 10 seconds as far as I remember, so you can try changing it to 60 seconds.

Change this:

w3 = Web3(HTTPProvider("..."))

To this:

w3 = Web3(HTTPProvider("...",request_kwargs={"timeout":60}))
1

Your code internally calls sendTransaction function that is not supported by Infura. Also you use w3.eth.accounts[0] which is also not supported. You need to use local private keys, when working with Infura. See Web3.py documentation for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.