All interactions I try on the web3py EthereumTesterProvider "blockchain" fail.

When the python progam does not crash, my transaction (deployment, setter) status is always 0 ('status': 0,)

For example, the following code, found at https://web3py.readthedocs.io/en/v5/contracts.html has 3 problems :

from web3 import Web3
from solcx import compile_source
from pprint import pprint

# Solidity source code
    compiled_sol = compile_source(
             "pragma solidity ^0.8.17;
             contract Greeter {
                 string public greeting;
                 constructor() public {
                     greeting = 'Hello';
                 function setGreeting(string memory _greeting) public {
                     greeting = _greeting;
                 function greet() view public returns (string memory) {
                     return greeting;
        output_values=['abi', 'bin']
    # retrieve the contract interface
    contract_id, contract_interface = compiled_sol.popitem()
    # get bytecode and abi
    bytecode = contract_interface['bin']
    abi = contract_interface['abi']
    # web3.py instance
    w3 = Web3(Web3.EthereumTesterProvider())
    # set pre-funded account as sender
    w3.eth.default_account = w3.eth.accounts[0]
    greeter_bin = w3.eth.contract(abi=abi, bytecode=bytecode)
    # Submit the transaction that deploys the contract
    # tx_hash = greeter_bin.constructor().transact()           # <==== first error
    tx_hash = greeter_bin.constructor().transact({'gas': 123456})
    # Wait for the transaction to be mined, and get the transaction receipt
    tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
    pprint(dict(tx_receipt))   # <===== second error ('status': 0,)
    greeter_obj = w3.eth.contract(address=tx_receipt.contractAddress, abi=abi)
    print(f"{greeter_obj.functions.greet().call() = }")      # <===== third error
    tx_hash = greeter_obj.functions.setGreeting('Nihao').transact()
    tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
    print(f"{greeter_obj.functions.greet().call() = }") 
  1. The first error takes place at the contract deployment: "TypeError: MockBackend.estimate_gas() takes 2 positional arguments but 3 were given." I fixed it by adding a dictionary with some gas but the exemple from Web3.py does not have this parameter. I'd like to know the reason. Did I miss something?

  2. The second problem is that the deploypment transaction status is ('status': 0,). Same problem for the setter below.

  3. The third problem is an error at greeter_obj.functions.greet().call() :

    "C:\Users\Gilles\AppData\Local\Programs\Python\Python310\lib\site-packages\web3\manager.py", line 170, in formatted_response apply_error_formatters(error_formatters, response) File "C:\Users\Gilles\AppData\Local\Programs\Python\Python310\lib\site-packages\web3\manager.py", line 70, in apply_error_formatters formatted_resp = pipe(response, error_formatters) File "cytoolz\functoolz.pyx", line 666, in cytoolz.functoolz.pipe File "cytoolz\functoolz.pyx", line 641, in cytoolz.functoolz.c_pipe File "C:\Users\Gilles\AppData\Local\Programs\Python\Python310\lib\site-packages\web3_utils\method_formatters.py", line 555, in raise_solidity_error_on_revert raise ValueError('Error expected to be a dict') ValueError: Error expected to be a dict

I also have the following Warning:

C:\Users\Gilles\AppData\Local\Programs\Python\Python310\lib\site-packages\eth_tester\backends_init_.py:30: UserWarning: Ethereum Tester: No backend was explicitly set, and no full backends were available. Falling back to the MockBackend which does not support all EVM functionality. Please refer to the eth-tester documentation for information on what backends are available and how to set them. Your py-evm package may need to be updated. warnings.warn(

So I tried to install py-evm "pip install py-evm" to try PyEVMBackend backend (instead of MockBackend), but the installation failed at pyethash dependency:

"D:\Program\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.34.31933\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\Gilles\AppData\Local\Programs\Python\Python310\include -IC:\Users\Gilles\AppData\Local\Programs\Python\Python310\Include "-ID:\Program\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.34.31933\include" "-ID:\Program\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" /Tcsrc/libethash/io_win32.c /Fobuild\temp.win-amd64-cpython-310\Release\src/libethash/io_win32.obj -Isrc/ -std=gnu99 -Wall
      clÿ: Ligne de commande warning D9002ÿ: option '-std=gnu99' inconnue ignor‚e
      c1: fatal error C1083: Impossible d'ouvrir le fichier sourceÿ: 'src/libethash/io_win32.c'ÿ: No such file or directory
      error: command 'D:\\Program\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.34.31933\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pyethash

Hopefully,if I can install pyethash and use PyEVMBackend, these issues will be fixed.

Can you please help me to fix pyethash installation problem. Or do you see something else I missed?

My pip config on windows 10 is:

  • web3py (5.31.3)
  • eth-tester (0.8.0b3)

1 Answer 1


I tried to put the answers to your question by number.

The first error is a TypeError when calling greeter_bin.constructor().transact(), which was fixed by adding a dictionary with some gas. The reason for this error is that the MockBackend used by the EthereumTesterProvider requires the gas parameter to be specified when making transactions.

The second issue is the status of the transaction being 0. This could be due to an error in the deployment or the execution of the transaction. It is also possible that the MockBackend doesn't properly handle the status field of a transaction receipt.

The third issue is a ValueError in greeter_obj.functions.greet().call() which is caused by the format of the response not being what the code is expecting. This could be due to the MockBackend not returning the correct format for the response.

  • Thanks Daniel. For all these reasons and as suggested in the UserWarning, I tried to switch to PyEVMBackend but I failed to install it on Windows 10 because of the pyethash dependancy. Have you installed PyEVMBackend on Windows?
    – u2gilles
    Feb 8, 2023 at 2:01
  • 1
    I work on MacOS so I can't really comment on that one.
    – f22daniel
    Feb 8, 2023 at 4:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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