Solidity is a
programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
for implementing
smart contract
A smart contract is a computer program or a Transaction Protocol Data Unit, transaction protocol that is intended to automatically execute, control or document events and actions according to the terms of a contract or an agreement. The objective ...
s
on various
blockchain
The blockchain is a distributed ledger with growing lists of Record (computer science), records (''blocks'') that are securely linked together via Cryptographic hash function, cryptographic hashes. Each block contains a cryptographic hash of th ...
platforms, most notably,
Ethereum
Ethereum is a decentralized blockchain with smart contract functionality. Ether (abbreviation: ETH) is the native cryptocurrency of the platform. Among cryptocurrencies, ether is second only to bitcoin in market capitalization. It is open-s ...
. Solidity is licensed under
GNU General Public License v3.0. Solidity was designed by
Gavin Wood
Gavin James Wood is an English computer scientist, a co-founder of Ethereum, and creator of Polkadot and Kusama.
Early life
Wood was born in Lancaster, England, United Kingdom. He attended the Lancaster Royal Grammar School. He graduated from ...
and developed by Christian Reitwiessner, Alex Beregszaszi, and several former Ethereum core contributors. Programs in Solidity run on
Ethereum Virtual Machine or on compatible virtual machines.
History
Solidity was proposed in August 2014 by
Gavin Wood
Gavin James Wood is an English computer scientist, a co-founder of Ethereum, and creator of Polkadot and Kusama.
Early life
Wood was born in Lancaster, England, United Kingdom. He attended the Lancaster Royal Grammar School. He graduated from ...
The language was later developed by the
Ethereum
Ethereum is a decentralized blockchain with smart contract functionality. Ether (abbreviation: ETH) is the native cryptocurrency of the platform. Among cryptocurrencies, ether is second only to bitcoin in market capitalization. It is open-s ...
project's Solidity team, led by Christian Reitwiessner.
Solidity is the primary language used to develop
smart contracts for
Ethereum
Ethereum is a decentralized blockchain with smart contract functionality. Ether (abbreviation: ETH) is the native cryptocurrency of the platform. Among cryptocurrencies, ether is second only to bitcoin in market capitalization. It is open-s ...
as well as other private
blockchains
The blockchain is a distributed ledger with growing lists of records (''blocks'') that are securely linked together via cryptographic hashes. Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data (g ...
, such as the enterprise-oriented
Hyperledger Fabric blockchain.
SWIFT
Swift or SWIFT most commonly refers to:
* SWIFT, an international organization facilitating transactions between banks
** SWIFT code
* Swift (programming language)
* Swift (bird), a family of birds
It may also refer to:
Organizations
* SWIF ...
deployed a proof of concept using Solidity running on Hyperledger Fabric.
Description
Solidity is a
statically typed programming language designed for developing
smart contracts that run on the
Ethereum Virtual Machine (EVM) or compatible virtual machines.
Solidity uses
ECMAScript
ECMAScript (; ES) is a standard for scripting languages, including JavaScript, JScript, and ActionScript. It is best known as a JavaScript standard intended to ensure the interoperability of web pages across different web browsers. It is stan ...
-like syntax which makes it familiar for existing web developers; however unlike ECMAScript it has
static typing
In computer programming, a type system is a logical system comprising a set of rules that assigns a property called a ''type'' (for example, integer, floating point, string) to every '' term'' (a word, phrase, or other set of symbols). Usu ...
and
variadic return types. Solidity is different from other EVM-targeting languages such as
Serpent and
Mutan in some important ways. It supports complex
member variables for
smart contracts, including arbitrarily hierarchical mappings and
structs. Solidity
smart contract
A smart contract is a computer program or a Transaction Protocol Data Unit, transaction protocol that is intended to automatically execute, control or document events and actions according to the terms of a contract or an agreement. The objective ...
support
inheritance
Inheritance is the practice of receiving private property, titles, debts, entitlements, privileges, rights, and obligations upon the death of an individual. The rules of inheritance differ among societies and have changed over time. Offi ...
, including
multiple inheritance
Multiple inheritance is a feature of some object-oriented computer programming languages in which an object or class can inherit features from more than one parent object or parent class. It is distinct from single inheritance, where an object ...
with C3 linearization. Solidity introduces an
application binary interface
An application binary interface (ABI) is an interface exposed by software that is defined for in-process machine code access. Often, the exposing software is a library, and the consumer is a program.
An ABI is at a relatively low-level of a ...
(ABI) that facilitates multiple
type-safe functions within a single
smart contract
A smart contract is a computer program or a Transaction Protocol Data Unit, transaction protocol that is intended to automatically execute, control or document events and actions according to the terms of a contract or an agreement. The objective ...
(this was also later supported by Serpent). The Solidity proposal also includes "Natural Language Specification", a documentation system for specifying user-centric descriptions of the ramifications of
method
Method (, methodos, from μετά/meta "in pursuit or quest of" + ὁδός/hodos "a method, system; a way or manner" of doing, saying, etc.), literally means a pursuit of knowledge, investigation, mode of prosecuting such inquiry, or system. In re ...
-calls.
Example of a Solidity program:
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;
contract Coin
Development IDEs
*
Microsoft Visual Studio Code
*
JetBrains IntelliJ
*
Remix Online Editor
Editor extensions
* Solidity Support for Visual Studio Code
* Solidity Support For IntelliJ
* Aderyn
Blockchain platforms
Solidity is available on:
*
Avalanche C-Chain
*
Binance Smart Chain
*
Counterparty
A counterparty (sometimes contraparty) is a Juristic person, legal entity, unincorporated entity, or collection of entities to which an exposure of financial risk may exist. The word became widely used in the 1980s, particularly at the time of the ...
(which runs on
Bitcoin
Bitcoin (abbreviation: BTC; Currency symbol, sign: ₿) is the first Decentralized application, decentralized cryptocurrency. Based on a free-market ideology, bitcoin was invented in 2008 when an unknown entity published a white paper under ...
)
*
Ethereum
Ethereum is a decentralized blockchain with smart contract functionality. Ether (abbreviation: ETH) is the native cryptocurrency of the platform. Among cryptocurrencies, ether is second only to bitcoin in market capitalization. It is open-s ...
*
Ethereum Classic
*
Tron
''Tron'' (stylized as ''TRON'') is a 1982 American science fiction action adventure film written and directed by Steven Lisberger from a story by Lisberger and Bonnie MacBird. The film stars Jeff Bridges as Kevin Flynn, a computer programmer ...
*
Hedera Hashgraph
* Polygon
*
Metis
* Arbitrum
* Optimism
ZKsync Era
Criticism
Many security properties of smart contracts are inherently difficult to reason about directly, and the
Turing-completeness
In computability theory, a system of data-manipulation rules (such as a model of computation, a computer's instruction set, a programming language, or a cellular automaton) is said to be Turing-complete or computationally universal if it can be ...
of Solidity means that verification of arbitrary properties cannot be
decidably automated. Current automated solutions for smart contract security analysis can miss critical violations, produce false positives, and fail to achieve sufficient code coverage on realistic contracts. Solidity has been blamed for the error-prone implementation of Ethereum smart contracts due to its counterintuitive nature, its lack of constructs to deal with blockchain domain-specific aspects, and its lack of centralized documentation of known vulnerabilities.
In 2016, a
Cornell University
Cornell University is a Private university, private Ivy League research university based in Ithaca, New York, United States. The university was co-founded by American philanthropist Ezra Cornell and historian and educator Andrew Dickson W ...
researcher stated that Solidity was partially to blame for
The DAO hack that took place that year. He stated: "this was actually not a flaw or exploit in the DAO contract itself: technically the
Ethereum Virtual Machine (EVM) was operating as intended, but Solidity was introducing security flaws into contracts that were not only missed by the community, but missed by the designers of the language themselves."
The developers community often cites Solidity requiring much of third party interfaces and APIs, and its inability to create critical information intensive smart contracts.
Comparison with other smart contract languages
Solidity vs. Rust
Solidity is the primary programming language for developing smart contracts on the Ethereum Virtual Machine (EVM). However,
Rust
Rust is an iron oxide, a usually reddish-brown oxide formed by the reaction of iron and oxygen in the catalytic presence of water or air moisture. Rust consists of hydrous iron(III) oxides (Fe2O3·nH2O) and iron(III) oxide-hydroxide (FeO(OH) ...
has emerged as a strong alternative in the blockchain ecosystem, especially for blockchains that support
WebAssembly
WebAssembly (Wasm) defines a portable binary-code format and a corresponding text format for executable programs as well as software interfaces for facilitating communication between such programs and their host environment.
The main goal of ...
(Wasm), such as
Polkadot,
Klever and
Solana.
Memory safety
Rust offers built-in
memory safety features that prevent common programming errors, such as
null pointer
In computing, a null pointer (sometimes shortened to nullptr or null) or null reference is a value saved for indicating that the Pointer (computer programming), pointer or reference (computer science), reference does not refer to a valid Object (c ...
dereferencing and
buffer overflows, which are not as rigorously enforced in Solidity. This makes Rust contracts potentially less prone to security vulnerabilities that could be exploited in smart contract environments.
Concurrency
Rust supports concurrent programming, which allows developers to write highly performant code that can handle multiple tasks simultaneously. This is particularly beneficial for high-performance blockchains like Solana, which need to process thousands of transactions per second. Solidity, on the other hand, does not natively support concurrency, which can limit its performance in certain applications.
Ecosystem integration
While Solidity is deeply integrated with the Ethereum ecosystem and its numerous development tools,
Rust is versatile and can be used across various blockchain platforms that leverage Wasm. Rust’s growing popularity is reflected in its adoption by new blockchain projects that prioritize performance and security.
Domain Specific Language
One of the major benefits of Solidity over other languages, is that it was designed specifically for smart contracts as a
domain specific language
A domain-specific language (DSL) is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains. There are a wide variety of DSLs, ranging ...
. This enables developers to build code with built-in smart contract capabilities lik
gasan
storagewithout having to have the language abstract the concepts out.
References
{{Cryptocurrencies
Domain-specific programming languages
Statically typed programming languages
Ethereum