Is owner > 0x0 a good way to test if an address owner was set in Solidity?
I am not sure if this could break something in the future and if there are better ways to see if the address was set. What is the best solution?

1 Answer 1


Though this works, I personally think it is a good idea to have both operand types equal on boolean operations , as you mentioned for future compatibility.

Instead of using > operator use equality == or != , as in case of address the greater operator may not make sense.

Instead of using 0x0 use address(0) or address(0x0), as it would make much more of type of address.

So your code would look like

owner==address(0);// check if the address is not set

Just my 2 cents

  • thanks, what is a Neo Noir Dev? Has it to do with Film Noir? Jul 2, 2016 at 20:14
  • 11
    Is there documentation for this address(0) somewhere?
    – JohnAllen
    Aug 20, 2017 at 18:18
  • 1
    it merely typecasts uint 0 to an address (0x000...) Jun 18, 2018 at 14:01
  • @JohnAllen as of Nov 2018, it doesn't seem so. Nov 13, 2018 at 8:31
  • @JohnAllen it is not documented per se in the Solidity documentation, but both contracts Voting and BlindAuction mention them : solidity.readthedocs.io/en/v0.5.11/…
    – CJ42
    Aug 15, 2019 at 9:38

Your Answer

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

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