I have an identical contract on the Mainnet and Ropsten. Both work fine in Remix. Using a python program on my Windows machine, I find that I get an error accessing the Ropsten contract, but not the mainnet version. All I changed in my Python program was the contract address and provider URL: "https://mainnet.infura.io/v3/3e4616a1aed64da3b29e20c2970e23b7" to "https://ropsten.infura.io/v3/3e4616a1aed64da3b29e20c2970e23b7"

The flawed program generates an error on the first contract call

currDay = contract.functions.currentDay().call()

This generates a scalar output, type uint8. The error I get is:

web3.exceptions.BadFunctionCallOutput: Could not decode contract function call currentDay return data b'' for output_types ['uint8']

As mentioned, this works fine for the mainnet, and also works fine within Remix for both the Ropsten and Mainnet contracts.


The contract address will be different on different networks. This is why the call fails.

  • As mentioned, I changed the contract address. The contract is identical, just one on Ropsten, one on the Mainnet. I then only changed the contract address and the provider URL to account for the difference. I suppose there's something in the python Web3 or HTTPProvider packages. – Eric Falkenstein Jul 28 '20 at 18:12
  • Looks like I was right :) – Mikko Ohtamaa Jul 29 '20 at 11:07

My bad: My program pulled in the Mainnet contract address from the json. This overwrote the correct address I posted above it. I forgot I had that address definition buried there, as it's redundant.

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.