Home Introduction to Solidity programming language
Post
Cancel

Introduction to Solidity programming language

Introducing Solidity

Solidity means the quality or state of being firm or strong in structure. Solidity is the language that is contract-oriented, high-level programming language whose syntax is similar to that of Javascript.It is designed to target the Ethereum virtual machine(EVM). Solidity is statistically typed and supports inheritance, libraries and complex user-defined data types among other features. You can start using solidity in your browser, no need to download or compile anything. This application only supports compilation if you want to run the code or inject into the blockchain you have to use a client or blockchain gateway service.

Solidity Basics

Solidity is an object oriented programming language for writing smart contracts. Developers ask “is solidity turning complete ?” An imperative language is turning complete if it has conditional branching such as if, while, for. Conditional looping statements, the ability to change an arbitrary amount of memory such as ability to maintain an arbitrary number of variables. Since this is the almost always the case most of it not all imperative language or turning complete if the limitations of finite memory are ignored. The commonly used to development languages C, C++, Java, Lua and Python all turning complete, as is solidity.

Let’s start with some basic code examples the first question to ask what is the current release of solid a when starting one should always go to the GitHub, which lists the release a new functionality for solidity. Once you know that then the second statement in the contract would be the release. If you look at the sample code below you will notice the specification of the current release of solid area at the time of this writing.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
StroageState
// COMMENT class or Contract named StroageState

pragma solidity ^0.4.16;
contract StorageState{
// COMMENT unassigned integer variable named stateData
    unit stateData;

/* COMMENT
The setter and the getter for variable named stateData
*/

    function set(unit x) {
        stateData = x;
    }

    function get() constant returns (uint) {
        return stateData;
    }
}

As mentioned the first line indicates that the source code is written in solidity Version 0.4.1 6 the keyword or directive progma(from “pragmatic”) is language construct that specifies how a compiler or translator should process its input.

A contract in solitary is code that includes the functionality on the data that execute on the record the state of the contract the contract assets at a specific address on the Ethereum blockchain this contract storage state if it were written in Java would be a bean. Java beans declare some variables and include creator and setter for each of the variables used to modify or retrieve the value of the variable the bean is usually adopted structure that is passed around class to class containing data we wish to share. The line unit stateData; declares state variable called stateData of type unit which is an unsigned integer of length 32 bytes. This contract, as mentioned, is a been following anyone to store a single number that is accessible by anyone publishing this number. Just as in Java, by declaring the variable private we pose access restrictions such that only the internal contract code can modify the variable. As you would expect single line comments(//) and multiple line comments(/*..*/) are specified as a depicted here.

We can talk about Solidity Control and Flow Statements in the next blog post.

This post is licensed under CC BY 4.0 by the author.