Solidity source files
You can identify a Solidity source file by the .sol
extension. It has various versions, as programming languages usually do. The latest version at the time of writing this book is0.4.17
.
In the source file, you can use the pragma Solidity
directive to mention the compiler version for which the code is written. For example:
pragma Solidity ^0.4.17;
It is important to note that the source file will not compile with compiler versions earlier than 0.4.17
and later than 0.5.0
(this second condition is added using ^
). Compiler versions between 0.4.17
and 0.5.0
are most likely to include bug fixes and less likely to break anything.
We can specify more complex rules for the compiler version; the expression follows those used by npm
.