đź”´ All about solidity 2022

đź”´ All about solidity 2022

·

2 min read

Introduction

Solidity, A statically typed programming language designed for developing smart contracts that run on the Ethereum Blockchain. This is situation whereby codes which are called smart contracts are deployed on the blockchain, like being used for creating decentralized voting systems and Dapps/defi or digital financial apps and also converting a digital file into a blockchain-based NFT.

This powerful language was proposed in August 2014 by Gavin Wood which is now the primary language on the Ethereum network as well as on other private blockchains platforms that compete with Ethereum.

Solidity is also an object-oriented programming language whereby Its syntax is very similar to scripting languages like JavaScript and also it was influenced by existing languages like C++, Python and JavaScript. his is how to write a smart contract in solidity

First you create a file app.sol

pragma solidity >=0.4.16 <0.7.0;

All solidity source code starts with the “pragma” keyword which is a declaration of the version of the solidity the compiler should use.

Then we have the contract keyword, this is also equivalent to class in other programming languages.

contract Test{
 //Functions and Data 
}

Then we have the state variables, The State variables are permanently stored in contract storage that they are written in Ethereum Blockchain.

uint public var1;
uint public var2; 
uint public sum;

Then the function declaration:

This is a public function that takes a variable x and variable y as a parameter. And these variables x and y are also summed to this variable here.

function set(uint x, uint y) public
function get() public view returns (uint)

conclusion

Well, This was an example of a simple smart contract which updates the value of variable 1 and variable 2. Anyone can call the function set and overwrite the value of these variables which is stored in Ethereum blockchain. This is an example of a decentralized application that is unaffected by the shutdown of any centralized server. As long as someone is running a single node of Ethereum blockchain, this smart contract will be accessible.

So now the question arises, how do we execute solidity smart contract 🤔 ?

There are practically two ways to execute a solidity smart contract:

To execute solidity offline, you will need to download and install node.js on your machine.

Then Install Truffle globally.

And also Install ganache-cli.

Then lastly the Remix IDE is generally used to compile and run Solidity smart contracts in the online mode.

This has been solidity in our today’s video, please be sure to like and subscribe for more related content, see you again in my next tutorial and as always, take care!

Â