I'm looking to ensure that an address is not the 0 address and with the update to 0.5.0 I am running into a TypeError Operator != not compatible with types contract GeneScienceInterface and address payable

function unpause() public onlyCEO whenPaused {
        require(geneScience != address(0));

  • Can you also add how you are declaring geneScience, because I'm not getting any error while comparing address(0) to regular address variable. – sp4c3 Jan 30 '19 at 17:48

That should work if geneScience is cast as an address. Since it doesn't work for you, I suspect it's a contract, which means you can't compare it to an address.

You can resolve that by using the address property of the contract.

require(address(geneScience) != address(0));

Hope it helps.

  • 1
    Funny, I've been doing this for quite some time now, and I wasn't aware of the myContract.address option, i.e., have always used address(myContract), which I assume is identical...? Or is this a Solidity 0.5.x feature? – goodvibration Jan 30 '19 at 18:44
  • Good catch. You're right about the syntax. I edited my answer to reflect that. – Rob Hitchens Jan 30 '19 at 19:16
  • Accidentally confused it with web3.js syntax I presume? – goodvibration Jan 30 '19 at 19:17
  • Unrelated: would you be able to refer to my question at ethereum.stackexchange.com/q/66382/16043? – goodvibration Jan 30 '19 at 19:39

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.