First, I'm caling function foo()
(from another contract) that returns me a uint
in the form of bytes
.
Then, I'm using BytesLib.toUint(foo(), 0)
to retrieve the uint
.
When the value is supposed to be 1
, foo returns 0x0000000000000000000000000000000000000000000000000000000000000001
, and BytesLib.toUint(foo(), 0)
works fine.
When the value is supposed to be 2
, foo returns 0x0000000000000000000000000000000000000000000000000000000000000002
, and BytesLib.toUint(foo(), 0)
works fine.
However, when the value is supposed to be 0
, foo does not return 0x0000000000000000000000000000000000000000000000000000000000000000
.
It returns 0x
. And BytesLib.toUint(foo()), 0)
does not work.
I would like to implement some logic to check if the value of foo()
equals 0x
. I've tried multiple things:
if (foo() == 0x) { //do something else }
if (foo() == "0x") { //do something else }
if (foo() == address(0)) { //do something else }
if (foo() == keccak256(0x)) { //do something else }
But all of these result in compilation errors.
How should I handle 0x
?