Programming in Solidity
In this section, we will be discussing the structure and elements of a Solidity source file; we will discuss the layout, structure, data types, its types, units, controls, expressions, and other aspects of Solidity. The format extension of a solidity file is .sol
.
Laying out a Solidity file
Solidity is going through active development and has lot of regular changes and suggestions from a huge community; hence, it is important to specify the version of a solidity file at the start of the source file, to avoid any conflict. This is achieved by the Pragma version. This is defined at the start of the solidity file so that any person looking to run the file knows about the previous version. Take a look at this code:
pragma solidity ^0.4.24;
By specifying a version number, that specific source file will compile with a version earlier or later than the specified version number.
Importing files
Similar to ECMAScript, a Solidity file is declared using the import
statement as follows...