I managed to successfully deploy a contract using Web3.py to the Ethereum Ropsten network using this bit of code
def deploy(self):
instance = self.w3.eth.contract(abi=self.abi, bytecode=self.bin)
construct_txn = instance.constructor().buildTransaction({
'from': self.pub,
'value': 10,
'gas': 1000000,
'gasPrice': w3.eth.gasPrice,
'nonce': self.w3.eth.getTransactionCount(self.pub),
})
signed = self.acct.signTransaction(construct_txn)
tx_hash = self.w3.eth.sendRawTransaction(signed.rawTransaction)
print(tx_hash.hex())
I then take the transaction hash, and pass it to this function to create a contract instance I can play around with using Python
def contract_in_concise_mode(contract_address):
# Contract instance in concise mode
abi = contract_interface['abi']
contract_instance = w3.eth.contract(address=contract_address, abi=abi, ContractFactoryClass=ConciseContract)
return contract_instance
But I am getting this error
web3.exceptions.InvalidAddress: ('Address must be 20 bytes, as a hex string with a 0x prefix', '0xa ....... 49')