blank
26
Jan

Solidity, the most used programming language to create Smart Contracts

Solidity, the most used programming language to create Smart Contracts

Blockchain technology is closer to our lives every day, little by little it is leaving the niche of early technological adopters to be present in our day to day. A few years ago Ethereum broke the market with the appearance of smart contracts (intelligent contracts) that added new functionalities to the block chain, Solidity is used to program them.

Solidity is an object-oriented programming language for writing smart contracts. Today it is used to implement smart contracts on various blockchain platforms, but it was born for Ethereum. Its first version was developed by Christian Reitwiessner and Alex Beregszaszi among others of the founding fathers of Ethereum. The goal of this language is the writing of smart contracts on blockchain platforms. Programs compiled by Solidity run on the Ethereum Virtual Machine.

Currently, in addition to being used to create smart contracts on the Ethereum network, it is used in other private blockchains that run on platforms that compete with Ethereum, such as Monax or BSC (Binance Smart Contracts). Solidity is a statically typed programming language designed to develop smart contracts that run on the Ethereum virtual machine, also known as the EVM.

It is designed using ECMAScript syntax to make it very accessible to web developers, with the particularity that its typing is static and its return types are variadic (it returns responses with a variable number of arguments). Allows the use of complex member variables for contracts, including arbitrary hierarchical assignments and structures. Contracts support inheritance, including multiple inheritance with C3 linearization. An Application Binary Interface (ABI) was also introduced that facilitates multiple type-safe functions within a single contract.

We show you here a very basic example of Solidity:

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.3;

contract Counter {

uint public count;

// Function to get the current count

function get() public view returns (uint) {

return count;

}

// Function to increment count by 1

function inc() public {

count += 1;

}

// Function to decrement count by 1

function dec() public {

count -= 1;

}

}

The most common environments to develop in Solidity are Remix, an online environment provided by the Ethereum network (https://remix.ethereum.org/), and Microsoft Visual Studio Code that has specialized plugins. In order to test the contracts, test networks such as Ropster, Kovan or Rinkeby are used. To perform network deployments from Javascript, the most used library is web3.js (https://web3js.readthedocs.io/)

Creating smart contracts today requires programming knowledge, but over time the technology will evolve so we hope over the years that it will be possible to write them for anyone who does not know how to program.

More articles by Gabriel Cuesta in Spanish