Solidity is a contract-oriented programming language used for writing smart contracts on the Ethereum blockchain. In this tutorial, we will discuss the syntax of Solidity.

Version Pragma

Version pragma specifies the version of the compiler that should be used to compile the contract. It is recommended to use the latest version available.

Example:

pragma solidity ^0.5.2;

The above code will compile with a compiler version >= 0.5.2 and < 0.6.0.

Import Files

Import statements allow us to use code from other Solidity files. There are three types of import statements:

  1. Import all symbols from a file:

    import "filename"
    
  2. Import all symbols from a file and assign a symbol to the file:

    import * as symbolName from "filename";
    

    or

    import "filename" as symbolName;
    
  3. Import only selected symbols from a file:

    import {symbol1 as alias, symbol2} from "filename";
    

Types

Solidity supports several data types, which include:

Boolean

The bool type in Solidity can have the values true or false.

Operators:

Example:

bool x = true;
bool y = false;