This page may contain legacy content

To get our most up-to-date content please access our documentation

June 22, 2021

Solidity Explained – What is Solidity?

Table of Contents

Odds are you’ve already heard of Solidity. Specifically, Solidity is an object-oriented programming language for writing smart contracts on blockchains like, most famously, Ethereum. At its core, Solidity is a programming language that is heavily influenced by JavaScript, Python, and C++, and Solidity targets the Ethereum Virtual Machine (EVM). Put simply, one could say that Solidity is the programming language of Ethereum.

As such, it is of vital importance for anyone looking to develop a Web3 app or dApps to have a basic understanding of Solidity. Granted, Moralis already gives developers some of the most sophisticated tools for developing serverless Web3 apps. However, knowing Solidity means you’ll be expertly suited for building Web3 apps with Moralis.

Moralis is a serverless, fully managed, and infinitely scalable Web3 backend infrastructure. If you want to check out all of the great Moralis features that have been open to the public since Moralis left beta with the release of its Moralis 1.0 “Enlightenment” Update, be sure to sign up for free today! Knowing Solidity allows you to code smart contracts easily and quickly.

What is Solidity?

The advent of Bitcoin over a decade ago spurred a new fever of development in the programming community. In the early days of crypto, some pioneers saw the potential of decentralized systems and decentralized consensus and started experimenting with ideas on how to expand the Bitcoin protocol’s fundamental ideas to other applications. 

Vitalik Buterin, an early advocate of Bitcoin, first proposed the creation of another protocol to run more elaborate smart contracts than that of the Bitcoin network. Bitcoin’s structure is simple, and for good reason – it was created primarily to be sound money. However, to do more complex transactions that do not require the presence of an intermediary to validate them, Buterin suggested the idea of Ethereum, a complex system of smart contracts interacting with each other. 

With Ethereum, the idea of a transaction was no longer limited to money per se, but a host of other types of arrangements that could be executed using a highly malleable and programmable protocol. In other words, Ethereum expanded the possibilities and brought creativity and a certain level of human-type problem-solving into the mix. As a result, this new blockchain protocol needed to be Turing complete (or as close to Turing completeness as possible) to achieve its new objectives. We’ll return to this notion of Turing completeness.

Understanding Solidity and Ethereum

Before you start frantically googling “how to learn Solidity”, it’s important to go back to the roots of this programming language and the Solidity smart contracts that form the transactional framework of Ethereum. 

Both Solidity and Ethereum are brilliant concepts built upon brilliant concepts. It all started with exploring the nature of calculation and computation itself, and the dream of machines that can approximate humans in their computing power. 

Ethereum is built upon the extensive history of dedicated work of noted cryptographers, mathematicians, and computer scientists. What’s more, it integrates many concepts, ranging from decentralization, immutability, states, networks, game theory, and so on. It’s also important to back-read on finite state machines. On your road to deciphering how to learn Solidity, you will encounter terms like Turing Completeness and Turing machines. As such, it is better to understand these concepts early in your journey.

What is Turing Completeness? 

To understand Soldity, we first have to take a look at Turing completeness and Turing machines. The term “Turing complete” itself hints at the origins of the concept of a Turing machine. As you may have guessed, the legendary Alan Turing had something to do with it. In his 1936 paper, “On Computable Numbers, with an application to the Entscheidungsproblem”, Turing imagined a machine that could solve any type of problem that humans are capable of solving. In short, a system of data-manipulation rules is seen as being Turing complete if it can simulate a Turing machine. The idea of Turing completeness preceded modern-day computers and came before the invention of RAM. It was an abstract definition of the meaning of computation and how it was performed. Solidity smart contracts have a relationship with Turing complete machines, as you will discover later. 

What is a Turing Machine? 

So, what is a Turing machine? Well, a Turing machine was originally imagined as being an infinite tape divided into squares, on which you can write and read data. The data takes the form of 1s and 0s, or binary code, which the machine then interprets into a set of symbols. This finite set of symbols is known as the machine’s alphabet. 

The machine has a computational – or read-write – head that can be moved along the tape and that can write or erase a symbol on a square. The computational head directs the machine’s attention to one square at a time, meaning the machine is “conscious” and aware of only a single square at any given time, depending on where the read-write head directs it.

In terms of movement, the computational head is limited to one space at a time. It can only move either left or right within a single space of its current position. The head can also read or write symbols at the particular square it is on. 

From this basic architecture, the machine can “compute” or “decide” which set of behaviors or operations to run based on what is called a “finite state machine”. Different types of Turing machines can be created whose operations are defined by their unique or respective state machines. In Turing’s paper, he mentions m-configurations, which refer to the finite number of states within a finite state machine. The machine switches between this fixed set of possible configurations.

Transition and Accept States in Turing Machines

In a Turing machine, you start with a given state at present and move to another resultant or future state. The phase between such states is called a transition state. 

While a machine is in its current state, it scans the current symbol and refers to a large table, known as a transition table, for instructions on what to do next. The transition state refers to the “undecided” phase wherein the machine is still looking up the table of possible next steps.

When you input a string in a Turing machine, you can envision it going into a transition table where the symbols direct you what to do next by moving either left or right across a series of states until it achieves a final state or accept state.

Accept states are what cause the machine to stop its execution. Entering into an accept state means that the machine will halt and has therefore permanently suspended the execution. This means that it cannot go into an infinite loop. Machines without accept states, on the other hand, never halt and run in continuous loops.

Ethereum mentions such states in its Ethereum yellow paper. An understanding of network states and what they mean for Ethereum will guide you on the journey as you find out the optimal shortcuts in figuring out how to interact with it and how to learn Solidity. 

The Universal Turing Machine

Turing machines can be as limited or expansive as they need to be. Such machines may, in theory, even be able to capture a wider set of computations and a degree of expression orders of magnitude proportional to the number of limited or specialized machines it assimilates. What does this mean, practically speaking?

A Universal Turing Machine, or UTM, would be able to simulate another Turing machine’s description number as an input. Turing has already laid out the state transition table for such machines. Today we can easily grasp the idea of a program being used as data and can, therefore, build software equivalents of “machines of machines”.

It opens up our ideas to endless possibilities. This concept of a universal Turing machine inspired the foundations of Ethereum.

Ethereum and Solidity Smart Contracts

To understand Ethereum, you first need to be familiar with the technology behind Bitcoin. This includes a basic understanding of how distributed ledgers work, how mining works, how nodes run, and what a blockchain is for. 

Bitcoin started the crypto revolution, but Ethereum took Bitcoin’s initial blockchain thesis and ran with it. Ethereum goes beyond data validation and storage in distributed ledgers. Using Ethereum, many different transactions and high-level functions can be performed, using multiple currencies or tokens (including Bitcoin) across an entire network. This network ensures that the code is run equivalently and that the resulting states are recorded and validated via consensus.

Ethereum is free and open-source software that runs on a decentralized network of computers. Being part of this network is voluntary. This network supports the Ethereum blockchain and ensures that programs called smart contracts are run using the voluntary participant computers or nodes.

The Ethereum Virtual Machine or EVM

Now that you have a conceptual grasp of Turing machines, the idea behind the Ethereum Virtual Machine, or EVM, should be easier to understand. The EVM is a virtual stack that is embedded within every fully participating node in the network, or Ethereum node, that executes contract bytecode. The EVM is a Turing complete system, which means it can perform any type of logical step associated with computational functions.

It forms one of the core components of the Ethereum protocol, allowing it to achieve consensus. Consensus in the protocol is achieved by executing smart contracts, whose outcomes are fully deterministic or guaranteed. It is also crucial to the economic design of Ethereum. While Bitcoin provides rewards for running a transaction, Ethereum charges fees for executing software instructions. The gas mechanism in Ethereum lets users pre-pay for the instructions they want to execute on the EVM using Ether, its native currency. 

EVMs are pretty versatile in that they can be implemented using JavaScript, C++, Ruby, Python, and a variety of other languages. Part of answering the question “What is Solidity?” is being able to understand its relationship with the EVM. 

What Solidity Does for Ethereum 

The contracts that are run using the EVM are written using Solidity. So, once and for all, what is Solidity? It is a high-level programming language that is compatible with how humans express instructions – using numbers and letters instead of binary code. While early Turing machines were founded on inputs of ones and zeros, Solidity does away with such complexity and humanizes the input process using more friendly code that is in many ways similar to JavaScript. 

Solidity smart contracts are instructions that are then compiled to the EVM’s bytecode. The nodes in the Ethereum network, as mentioned, run EVM instances that permit them to agree on the execution of the same set of instructions. 

History of Solidity: From v0.1.0 to the Future

Solidity was first proposed by Dr. Gavin Wood, the first CTO of Ethereum, in 2014 and further developed by Christian Reitwiessner, who led a team of developers to move it forward. It is around six years old at the time of this writing. Its core team, until today, is sponsored by the Ethereum Foundation, and it has a broad community of supporters and a long list of contributors who keep helping in its development through commits, filing bug reports, and actively threshing out issues on Github and beyond. 

Its first publicly named version was v0.1.0. Since then, it has undergone many improvements and iterations. Consequently, the answer to “What is Solidity?” keeps evolving.

Solidity was designed to lower the entry barrier to Ethereum, which means that it had to be the simplest, easiest-to-use language for smart contracts. In the beginning, Solidity smart contracts had qualities that reflected such goals, including a syntax that is very similar to JavaScript and a noticeable lack of features. There were some clear trade-offs in the language to make it user-friendly.

Over time, security became paramount. Ease of use gave way to changing priorities, and today’s Solidity smart contracts can be explicit and verbose because of this. Today, when you ask, “What is Solidity?” you will likely end up with a description that includes its long-windedness versus the straightforwardness of other computer languages. 

Solidity is the First Contract-Oriented Language

One of the most important things to keep in mind when exploring how to learn Solidity is that Solidity is a language specifically designed to target the Ethereum Virtual Machine, or EVM. 

It has many similarities to JavaScript, or JS. If you already know JavaScript, then it will be easier to learn Solidity. There are of course variations in the syntax. However, from a command and conceptual point of view, the languages are quite alike. 

As the native language of Ethereum, unlike its close kin JavaScript, you will have built-in commands. This is done for Solidity to access a part of the blockchain—say, a timestamp or address of a particular block. You have these built-in functions that allow you to program Solidity smart contracts with ease. 

A contract-oriented language differs from largely object-oriented languages like Java and C++ in that its emphasis is on contracts and functions. Solidity is typed statically. It also supports libraries, inheritance, and other user-defined features which tend to be more complex. The language compiles all the instructions into a sandbox of bytecode so that these instructions can be read and interpreted in the Ethereum network.

Solidity Smart Contracts

Ethereum’s goal was to tackle and execute human-level transactions, much like the ambitions of the Turing complete machine. To do this, it needed to adopt human-level logic in a degree of simplicity that was friendly to programmers on the one end, and to execute Solidity smart contracts on a Turing complete system, touted as a Turing complete virtual machine, that allowed for an unprecedented level of complexity and certainty on the other.

The processing capability of such a “virtual” machine is embedded in its node implementation, a remarkable feat of decentralization, and the product of the innovation of the blockchain movement. 

Solidity smart contracts allow anyone who participates in the network – basically, any person in the world who wants to – to transact with others they don’t personally know or trust. They may not even use the same currency. Solidity smart contracts programmatically set the rules of a business transaction, and they do this in a simplified machine-readable language. Such unprecedented decentralized business is automated and able to run without human and trusted-party supervision globally and 24/7. 

So, again then, what is Solidity? Its more high-level human-friendly standpoint may make it a bit more verbose than other programming languages, but at heart, it attempts something that has never been attempted before – namely to bridge human and machine reasoning, that does not involve the human becoming more machine-like but adapts machine logic to human needs. It is remarkable that as a tool with a compiler it allows us to express ourselves easier in code, and takes our human-readable code and transforms it into a business function. 

Apart from Solidity, are there other languages on Ethereum?

Yes, there are. There are other languages, such as Serpent, which can be similarly compiled into the Ethereum Virtual Machine’s bytecode. While Serpent and the other “EVM-compilable” languages are beyond the scope of this article, it is worth noting that they all perform essentially the same function, which is generating EVM bytecode that can be run on nodes in the network.

How to Learn Solidity?

Coding Solidity smart contracts may be your next great adventure as a programmer. It will open new doors to the field of blockchain and its many in-demand applications, and it can give you initial access to Web3, which is transforming the internet as we speak. Understanding Solidity and Web3.js will complete your knowledge of Ethereum. Many resources will guide you on how to learn Solidity.

How to learn Solidity Using the Best Online Courses

If your programming interest has been piqued, you can look up some of the best resources on the web to make sure you are off to an excellent start. 

Ivan on Tech Academy’s platform provides top-notch instruction on how to learn Solidity and coding Solidity smart contracts. You’ll also learn about the relationships between Solidity and Web3.js. Go to Ivan on Tech Academy now and discover how understanding the Ethereum blockchain and learning to create smart contracts can help you power up and transform your perspective!

Working and Building with Solidity and Web3.js

Another aspect of developing on Ethereum is the need to understand how the Web3.js library enables your interaction with the main blockchain. The foundational aspect of this is a solid competency in JavaScript. You need JavaScript skills to be able to work with both Solidity and Web3.js. 

The direct relevance JavaScript knowledge to coding and interacting with the Ethereum blockchain cannot be emphasized enough. Using Solidity and Web3.js, you integrate dApps or decentralized apps into the ecosystem. Your Web3.js library is used to point to the Ethereum blockchain to execute a specific function. Decentralized apps or dApps are applications that do not exist directly on the blockchain but use it to validate and store data and perform other functions. Web3.js helps such dApps to access the blockchain. 

The best way to bridge your theoretical JavaScript knowledge with practical blockchain applications is, of course, by using Moralis. Moralis makes Web3 app and dApp development easy. If you need a quick into to JavaScript, feel free to learn it through the highly-rated Ivan on Tech Academy course, JavaScript for blockchain developers

Simplify your dApp Development with Moralis

If you are an intermediate or advanced developer who is looking to fast-track your dApp projects, Moralis is an incredible boost to your productivity. Moralis allows you to focus on the features and user-friendliness of your dApp, while ensuring perfect and effortless execution on the back-end. In fact, you can ship your dApps in record time by checking out Moralis’ official documentation

Benefits of Learning Solidity

What is Solidity? Apart from its technical definition, one could say it’s a programming language that puts you on your next level of advancement and opens doors to new opportunities. As a developer, you’re always looking to grow and be in step with the latest trends in programming.

If you’ve been looking into getting into blockchain development, Solidity can be your entry point. With Solidity, you’ll be learning more than just a language or a skill. You’ll get the chance to contribute to the Ethereum ecosystem, work and interact with teams all over the world, be more employable and join amazing projects, be part of an amazing community with numerous discussion boards and touchpoints, and, last but not least, be an entrepreneur and invent a new application! Solidity is usually almost a prerequisite for creating Web3 dApps, but Moralis makes it easier than ever with Web3 app development. Leverage Moralis’ powerful native support for IPFS and authentication support for MetaMask, along with Moralis’ truly magic Speedy Nodes blockchain node provider functionality. Moralis lets you develop dApps and Web3 apps in minutes instead of days!


Moralis Money
Stay ahead of the markets with real-time, on-chain data insights. Inform your trades with true market alpha!
Moralis Money
Related Articles
October 6, 2022

Fantom Joins Moralis x Google Defining DeFi Hackathon as Gold Tier Sponsor

February 23, 2024

Moralis Launches Wallet Net Worth 

January 18, 2024

Moralis Introduces Why Did It Move API 

October 5, 2022

Polygon Joins Moralis x Google Defining DeFi Hackathon as Gold Tier Sponsor

May 1, 2024

Moralis Adds Support for Moonbeam Network

October 4, 2022

BNB Chain Joins Moralis x Google Defining DeFi Hackathon as Gold Tier Sponsor

February 2, 2024

Moralis Announces OP Mainnet Support

September 8, 2022

Introducing Self-Hosted Moralis Servers

November 15, 2022

Moralis Introduces Support for the Optimism Network