Understanding solidity

Understanding solidity

Breaking down the meaning and characteristics of the solidity language

·

5 min read

Block greetings, great builders

Web3 Afrika - images

As per person wey dey familiar with this web 3 space, you go don hear about this term "solidity". For this article, I go like explain wetin he be.

The first time wey I go search for the meaning of solidity, na the definition wey dey the documentation I first see.

Solidity is an object-oriented, high-level language for implementing smart contracts. Solidity is a curly-bracket language designed to target the Ethereum Virtual Machine (EVM). It is influenced by C++, Python and JavaScript. Solidity is statically typed, supports inheritance, libraries and complex user-defined types among other features.

As I see am, the first ting wey commot my mouth na "omoooo". If na the same thing you say abi you sef no get am, no shaking, we gather dey, na why I write this article. Make we enter the matter now.

Solidity Is Object Oriented

If you don dey code before, you go don hear of or dey familiar with the concept of object oriented programming but if e new to you, sit back, sip your drink and relax, I go explain.

Object oriented programming na concept for programming wey mean say when you dey write programs, you dey represent the important parts like an object. Make we assume now say you dey build Asphalt 9 wey be racing game, you fit represent each car as an object wey go get properties like color, model, brand and functionalities like brake, speed, turn left or right. Basically na wetin OOP mean be this. So each smart contract wey solidity dey create na object.

Solidity Is a High-level Language

Wetin be high-level language? In the simplest of terms, high-level language na language wey dey human readable. If you dey look the syntax e go be like say you dey read normal sentence. For example;

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;


contract DemoContract 
{
    uint storedData;

    function set(uint x) public 
    {
        storedData = x;

         if (storedData < 50)
        {
            storedData = storedData*0;          
        }
        else
        {
            storedData = storedData*2;
        }

    }

    function get() public view returns (uint) 
    {
        return storedData;
    }

}

If you never write solidity before, calm down first. Forget everything else just start by focusing on storedData = x; you go see say just like normal maths for secondary school wey you dey run away from that year, you understand say wetin that line mean be say we dey assign x to be the value ofstoredData , so storedData na something wey we dey call variable

Next line talk say if anything wey dey inside storedData dey less than 50, the new value of storedData go be 0 or else if that condition i.e storedData < 50 no true, the old value of storedData go dey multiplied by 2.

You see say e dey easy to read. Na why dem dey call am high-level language. E go mean as low-level language go dey now? True. That one na the opposite of high-level language, we no fit read am, na the language wey computer fit read.

So when we write high-level code for computer, something wey dem dey call compiler go convert am to low-level code wey computer fit read.

Other examples of high-level languages na JavaScript, Python

Solidity is Influenced by other Languages like C++, Python and JavaScript

Solidity na just dialect of a language.

You fit see solidity as this pidgin wey I dey talk, we dey borrow normal English and Igbo even sometimes Yoruba.>

If you don dey code for the best programming language wey be JavaScript (you no agree? We go fight our fight after the service. Meet me on my TL), you go see say solidity and JavaScript get many things in common, like the camel case naming convention of variables i.e starting the first letter of the variable with lowercase and the next word starts with uppercase e.g storedData also you go see say each statement dey end with semicolon.

So if you sabi either of these languages, learning solidity go soft for you.

Solidity is Used to Develop Smart Contracts

Just as we dey used JavaScript for web development and many other things, we dey use python for backend development and AI/ML, na smart contracts we dey use solidity do.

Smart contracts na code wey dey run or execute when some conditions are met.

We fit say if stream wey peace be unto you get, make #500 dey enter Asake aza. So everytime wey person stream that song, the smart contract code go execute and Asake go get him alert as the omo ope wey him be.

Solidity is Statically Typed

Unlike other languages wey be say if you wan define data types, you no need specify, no be so for solidity my comrade.

Web3 Afrika - images

For here, we dey specify if na string, positive integer, negative integer and so on. Make I sharparly run you one example.

If I wan define string for JavaScript now, make we use person name

const name = 'Faustina'; // string in Javascript

No ask me why I use woman name, focus on wetin I dey teach you comrade, drink water and mind your business.

Now let make we write this same code in solidity.

pragma solidity ^0.8.10;

contract SolidityTest {
   string name = "Faustina"; // string in solidity
}

You see say for solidity, we need to specifically tell am say "boss, na string be this o". I Sabi say e stressful especially for us wey dey come from other languages wey we no dey specify but we go dey alright.

Solidity is a Curly Brackets Language

This one na one feature wey solidity borrow from C++

Wetin e mean be say the code wey we dey write for solidity, we dey always enclose am inside curly brackets { }

Make we round up now, other things we I go like mention na say you fit define your own data types, you fit import libraries, you fit do inheritance.

I hope say you no only learn something, you also enjoyed yourself.

If you read to the end, one cold origin for you, if you no dey drink, manage malt or you fit do like me and take Capri Sun.

Till we meet again, keep building.

Freshly minted with love ❤️