Table of Contents

What is Solidity? Everything You Need to Know

Published on 
April 10, 2023
A Clock
7
mins
Tag: 
Solidity
Table of Contents

The ranks of developers transitioning from traditional web development to web3 are constantly rising as the wider world of web3 continues to grow.

Likewise, that rapid growth has spawned new disciplines to learn, development platforms to build on, skills to acquire, and, more particularly, programming languages to master.

As web3 matures as a technology and industry, developers are spoiled with an abundance of the various programming languages associated with web3. Each language within the gamut of web3 was developed to bring a diverse set of advantages and drawbacks for writing smart contracts.

For instance, programming languages may vary depending on which particular blockchain they support. Other programming languages may differ in their individual characteristics, such as security, speed, access, and readability.

Solidity is the most prevalent smart contract programming language used in web3. Solidity is a robust, expressive programming language developed precisely to create smart contracts and decentralized applications (dapps) for the Ethereum blockchain – the blockchain that boasts the largest number of developers across blockchain platforms and protocols.

Solidity has evolved by leaps and bounds since its inception in 2014 by Ethereum co-founder Gavin Wood and its subsequent development by the Ethereum Solidity team helmed by Christian Reitwiessner.

Today, thousands upon thousands of developers use Solidity to write smart contract code and enable, verify, and run Solidity smart contracts across various use cases. These include cryptocurrencies, decentralized finance (DeFi), non-fungible tokens (NFTs), GameFi, or everything else that falls within the scope of web3.

This article explains what Solidity is and how it is used in the Ethereum ecosystem. This article is for you if you're interested in learning more about the inner workings of this blockchain-based programming language.

What is Solidity?: An Introduction

Solidity is an object-oriented, high-level programming language created specifically for constructing, designing, and implementing smart contracts that are executed on the Ethereum Virtual Machine (EVM). Solidity is based on established and renowned programming languages such as JavaScript and C++. Every developer aiming to make it in web3 will want to have a strong foundation in the language – and prior knowledge of the aforementioned languages will give you an edge.

The following sections will discuss the origins of Solidity and determine the common features that Solidity and other programming languages have, as well as expound on the programming language's main use cases.

A Brief History of Solidity

Back in 2014, Ethereum co-founder Gavin Wood first proposed the development of a programming language that would be suitable for the then-nascent blockchain's requirement to have a Turing-complete programming language to create smart contracts.

Meanwhile, Ethereum founder Vitalik Buterin laid out his vision for the blockchain as a protocol that would iterate on the distributed ledger technology that Bitcoin first laid the groundwork for, but with the added utility and function of Ethereum smart contracts. Buterin's vision for Ethereum would be its ability to run a complex, a high-functioning network of smart contracts – essentially pieces of code that automatically execute agreements that run on a distributed network of nodes or computers.

Christian Reitwiessner, Ethereum team lead and researcher, assembled the project team tasked to oversee the development of Solidity. Reitwiessner, former Ethereum co-lead Alex Beregszaszi, and a few other Ethereum core contributors – creating the the Turing-complete, high-level programming language that ultimately became the bedrock of what we know as web3 today.

For extra context, Turing-completeness refers to the ability of a programming language – or any data manipulation system – to be able to perform any computation needed from it. 

In theory, the vision behind Solidity is to be able to perform any computation a developer might ask from ut. The "Turing" part is a reference to Alan Turing's hypothetical computer that can use predefined rules to identify a result from a collection of input variables – known as a Turing machine.

What programming languages was Solidity based on?

Solidity was developed and informed by using several established programming languages early in its development – most notably, JavaScript, Python, and C++.

In this section, we'll take a look at some of the similarities Solidity shares with the aforementioned languages.

Solidity and C++

Solidity draws from C++ and its syntax, particularly when it comes to loops and variable declarations. Solidity also supports function overloading, an object-oriented feature in C++ needed when two functions share the same name while each accepting different parameters.

Lastly, Solidity also enables type conversion, particularly implicit and explicit type conversions. This enables variables types to be cast by developer code, or if it will be converted automatically whenever a computation requires it.

Solidity and JavaScript

Solidity used to draw heavy influences from JavaScript. Now, however, the only primarily distinguishable similarity to JavaScript is that functions are defined using the keyword function.

Developers familiar with Solidity's main influences will find Solidity to be relatively simple. Solidity also allows the use of libraries and creating complex types due to its statically typed nature.

Solidity and Python

Solidity doesn't derive much influence from Python as far as syntax is concerned. The key similarities between Solidity and Python lie in the features of multiple inheritance and C3 linearization.

How do developers use Solidity?

True to its disposition as a language used for blockchain coding, Solidity was developed expressly for the purpose of being compiled on the Ethereum Virtual Machine (EVM). Therefore, using Solidity enables developers to write smart contracts compatible with Ethereum for any blockchain protocol compatible with the EVM.

Solidity's widespread compatibility, along with its flexibility, functionality, and intuitiveness, made Solidity one of the most prevalent programming languages for blockchain development in the web3 space.

Solidity 101: How does it work?

Developers using Solidity create smart contracts. Smart contracts, in essence, are programs that run on the Ethereum Virtual Machine. Smart contracts may contain a variety of functions, pubic declarations, and internal states.

Solidity smart contracts are compiled into bytecode for the Ethereum Virtual Machine to process and run. After the process of compilation, Solidity smart contract code will look indistinguishable from other smart contracts written in programming languages like Vyper, which is an example of a Python-inspired smart contract language written for the EVM.

Solidity is also subject to periodic version updates, as would any other developer tool. We do need to note that since smart contracts are immutable and, therefore, cannot be reversed after being deployed on-chain, versioning concerns only matter at the time of the smart contract's creation.

For instance, every line of source code on every Solidity smart contract – even on a simple, smart contract – should begin with a declaration of which version of the Solidity compiler to use for that particular piece of code. This declaration of the Solidity program version to be used on a smart contract is called the "version pragma."

In theory, any Solidity dev can write a smart contract for Ethereum directly using bytecode; however, Solidity, which is a high-level programming language, enable devs to write more efficient, tighter code without the need for any other low-level processing.

Solidity and the Ethereum Virtual Machine: How do they interact?

Here's a quick rundown on how Solidity works with the EVM, particularly when it comes to changes in state:

  1. First, smart contracts are written in Solidity
  2. The Solidity smart contracts are then compiled to bytecode
  3. The EVM converts bytecode into opcodes, which are predefined instructions that the EVM reads, processes, and executes
  4. The freshly-converted EVM opcodes then change the Ethereum Virtual Machine itself.

In a nutshell, the Ethereum Virtual Machine serves as a record keeper and virtual state machine for the "world computer" that is Ethereum. A state machine is a machine crafted to read inputs and changes its state based on those said inputs.

The EVM basically maintains the Ethereum network's global state, which contains data such as account balances, token ownership, and wallet addresses, to name a few.

Therefore, Solidity devs write smart contracts as input for the Ethereum Virtual Machine to change its state. The global state of the EVM changes when actions such as minting NFTs, sending or receiving ERC-20 tokens, or releasing assets from escrow are performed.

A variety of EVM operations, written into opcodes for the EVM, causes these desired changes to the global state. Every opcode is intended to instruct the EVM to perform some form of state change, such as sending or receiving cryptocurrencies, burning or destroying smart contracts, or minting NFTs or digital currencies.

Finally, the EVM translates the bytecode contained in the smart contract into opcodes for the EVM, which will perform the requested changes on-chain.

Each opcode has a particular transaction or "gas" fee charged in Ethereum to reduce the risk of fraudulent or malicious actors slowing down the network for everyone else by sending an inappropriate amount of requests. Gas fees are calculated by multiplying the total gas cost of a transaction's opcodes with the price per gas unit.

Do other blockchains support Solidity?

Solidity can be used to write and run smart contracts for any blockchain network that is compatible with the EVM. This include layer 2 scaling solutions like Polygon/MATIC and Arbitrum. Solidity is supported by a variety of other blockchain ecosystems due to its ease of use and flexibility. Here are several blockchains that support Solidity.

  • Ethereum
  • Ethereum Classic.
  • Avalanche (AVAX)
  • BNB Chain (ex-Binance Smart Chain)
  • Polkadot (DOT)
  • Counterparty (running on Bitcoin)
  • Tron (TRX)
  • Hedera Hashgraph (HBAR)

We can expect this list to grow exponentially in the future as distributed ledger technology gains wider adoption and works toward achieving interoperability.

Ethereum Request for Comment (ERC) Standards and Solidity

One way to learn about the underlying design of Solidity smart contracts are ERC (Ethereum Request for Comment) standards. ERC standards refer to specifications made to standardize the implementation of digital assets on Ethereum such as fungible and non-fungible tokens.

These standards are put forward for approval using Ethereum Improvement Proposals, or EIPs. Once approved and finalized, ERC standards become a common Solidity template, as it were, for writing certain types of smart contracts on Solidity.

When Solidity devs create projects using established ERC standards, they will know exactly how their tokens will perform on-chain.

The following is a list of the most commonly-used ERC standards in web3.

  • ERC-20. The standard for fungible tokens, such as digital currencies, governance tokens, and tokens for staking.
  • ERC-721. The standard for non-fungible tokens (NFTs) could be any piece of content, such as photos, songs, or PFPs.
  • ERC-1155. The standard for semi-fungible tokens enables the creation of both utility tokens and NFTs. They allow more efficient trading and transaction bundling, which saves on gas fees.
  • ERC-4626. The standard streamlines and synergizes the technical parameters of yield-bearing vaults.

The final word on Solidity

As of 2023, the web3 industry was valued at US$2.86 billion. Experts forecast that the demand for web3 will hit the height of US$116.5 billion by 2033. These numbers are only going to increase as web3 further matures as industry gains greater adoption in the coming years.

It's clear that web3 is here to stay – and Solidity programming will be one of the building blocks of its bright (and potentially lucrative) future.

Learning core web3 technologies such as Solidity may seem like a tall task at first – but as the droves of developers making the switch to web3 indicate, anyone and everyone can do it.

Solidity is part and parcel of the emerging web3 stack. Quite frankly, there are hundreds of thousands of reasons to learn Solidity, considering the average web3 dev salary easily ranges from $100-$200k a year. Good job, if you can get it!

There's no better time to learn Solidity than today. If you're serious about jumping into the exciting web3 space full-time, do yourself a favor and invest in learning Solidity. There's more free and paid resources out there than you can shake a stick at.

Trust us – you'll thank us later.

Subscribe for weekly updates!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Join Metacrafters Today! 

Become a Crafter and start your Web3 journey by enrolling in our FREE module.
Sign Up
Placeholder Image