Boolean
Solidity, like any programming language, provides a boolean data type. The bool
data type can be used to represent scenarios that have binary results, such as true
or false
, 1
or 0
, and so on. The valid values for this data type are true
and false
. It is to be noted that bools in Solidity cannot be converted to integers, as they can in other programming languages. It's a value type and any assignment to other boolean variables creates a new copy. The default value for bool
in Solidity is false
.
A bool
data type is declared and assigned a value as shown in the following code:
bool isPaid = true;
It can be modified within contracts and can be used in both incoming and outgoing parameters and the return value, as shown in the following screenshot: