S1E2:Hello Solidity

S1E2:Hello Solidity

Hey guys, we're going to write our first Hello World in Solidity, Let's Get Started. We're going to use the Remix IDE cloud editor from Ethereum. An open source IDE to write, compile and deploy your solidity code into the Ethereum Virtual Machine (EVM). To understand the Remix IDE interface, Click here for quick info. Open your Remix IDE and type the code that follows.


pragma solidity ^0.7.0;

// Our first Solidity code
contract DataTypes{
    /*
    Created a variable
    name="Hello solidity"
    */
    string public name="Hello Solidity";

}

Volla! We wrote our first Code in Solidity. Lets have a run through the solidity file structure. There are primarily 4 high-level elements that reside in a solidity file:

Pragma, import, coments and contracts

  • Pragma: The keyword pragma is a directive that specifies which version of the compiler is used in our Solidity Code.You declare a pragma by writing
pragma solidity ^0.7.0;

This code explains we are using the latest build in version 0.7 This will prevent your code from breaking when new changes are made to the compiler.

  • Import: Like any other high level programming language, you can import other solidity files or libraries.

  • Comments:Comment are used in describing a portion of your codes and its a great way to allow you understand what your code is doing. There are two types of comments: the single line and the multiline comments.

// This is a single line comment

    /*
    This is a
     multiline comment
    */
  • Contract:Contract in solidity is like a class in other high level language. all data and functions are written inside the contract's curly braces.

We'd talk about Contract in the next episode, see you later!.