I have opened an instance of ganache at localhost port 9545 where I can connect with web3.py. However when I am trying to perform a transact using the below code:

w3 = Web3(Web3.HTTPProvider(''))

ExampleContract = w3.eth.contract(abi=abi, bytecode=bytecode)

tx_hash = ExampleContract.constructor().transact()

I am getting the following error:

ValueError: {'message': 'from not found; is required', 'code': -32000, 'data'

This is straight from the documentation here

Any ideas?

  • 1
    Try ExampleContract.deploy({'from': web3.eth.accounts[0], 'gasPrice': web3.eth.gasPrice, 'gas': web3.eth.getBlock('latest').gasLimit}) – goodvibration Nov 9 '20 at 20:48
  • Or simply use transact({'from': web3.eth.accounts[0], 'gasPrice': web3.eth.gasPrice, 'gas': web3.eth.getBlock('latest').gasLimit}) in your own code. – goodvibration Nov 9 '20 at 20:50
  • It worked. Thanks – spyrAlex Nov 14 '20 at 19:04

Like the comments say, you need to have the 'from' address defined in your transaction parameters. Geth changed that requirement a few releases ago. So:

tx_hash = ExampleContract.constructor().transact({'from': <address>})

  • It worked with the 'From'. Thanks – spyrAlex Nov 14 '20 at 19:05

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.