Pragma

Pragma is generally the first line of code within any Solidity file. pragma is a directive that specifies the compiler version to be used for current Solidity file.

Solidity is a new language and is subject to continuous improvement on an on-going basis. Whenever a new feature or improvement is introduced, it comes out with a new version. The current version at the time of writing was 0.4.19.

With the help of the pragma directive, you can choose the compiler version and target your code accordingly, as shown in the following code example:

pragma Solidity ^0.4.19;

Although it is not mandatory, it is a good practice to declare the pragma directive as the first statement in a Solidity file.

The syntax for the pragma directive is as follows: ...

Get Solidity Programming Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.