Solidity

Last updated

Solidity
Solidity logo.svg
The Solidity language logo
Paradigm Imperative
Designed by Gavin Wood
Developer Christian Reitwiessner, [1] Alex Beregszaszi, [2] and several former Ethereum core contributors.
First appearedAugust 2014
Stable release
0.8.28 [3] / 9 October 2024;2 months ago (9 October 2024)
Implementation language C++ [4]
License GNU General Public License v3.0 [5]
Filename extensions .sol
Website soliditylang.org
Influenced by
JavaScript, C++, Python

Solidity is a programming language for implementing smart contracts [6] [7] on various blockchain platforms, most notably, Ethereum. [8] Solidity is licensed under GNU General Public License v3.0. [9] Solidity was designed by Gavin Wood [10] [ non-primary source needed ] and developed by Christian Reitwiessner, Alex Beregszaszi, and several former Ethereum core contributors. [11] Programs in Solidity run on Ethereum Virtual Machine or on compatible virtual machines. [12]

Contents

History

Solidity was proposed in August 2014 by Gavin Wood [13] [ non-primary source needed ] The language was later developed by the Ethereum project's Solidity team, led by Christian Reitwiessner.

Solidity is the primary language used to develop smart contracts for Ethereum as well as other private blockchains, such as the enterprise-oriented Hyperledger Fabric blockchain. SWIFT deployed a proof of concept using Solidity running on Hyperledger Fabric. [14] [15]

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. [16]

Solidity uses ECMAScript-like syntax which makes it familiar for existing web developers; [17] however unlike ECMAScript it has static typing 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 support inheritance, including multiple inheritance with C3 linearization. Solidity introduces an application binary interface (ABI) that facilitates multiple type-safe functions within a single smart contract (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-calls. [18] [19] [ non-primary source needed ]

Example of a Solidity program: [20] [21]

// SPDX-License-Identifier: GPL-3.0pragma solidity^0.8.4;contractCoin{// The keyword "public" makes variables// accessible from other contractsaddresspublic minter;mapping(address=>uint)publicbalances;// Events allow clients to react to specific// contract changes you declareeventSent(addressfrom,addressto,uintamount);// Constructor code is only run when the contract// is createdconstructor(){minter=msg.sender;}// Sends an amount of newly created coins to an address// Can only be called by the contract creatorfunctionmint(addressreceiver,uintamount)public{require(msg.sender==minter);balances[receiver]+=amount;}// Errors allow you to provide information about// why an operation failed. They are returned// to the caller of the function.errorInsufficientBalance(uintrequested,uintavailable);// Sends an amount of existing coins// from any caller to an addressfunctionsend(addressreceiver,uintamount)public{if(amount>balances[msg.sender])revertInsufficientBalance({requested:amount,available:balances[msg.sender]});balances[msg.sender]-=amount;balances[receiver]+=amount;emitSent(msg.sender,receiver,amount);}}

Development IDEs

Editor extensions

Blockchain platforms

Solidity is available on:

Criticism

Many security properties of smart contracts are inherently difficult to reason about directly, and the Turing-completeness 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. [29] 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. [30]

In 2016, a Cornell University 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." [31]

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). [32] However, Rust has emerged as a strong alternative in the blockchain ecosystem, especially for blockchains that support WebAssembly (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 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, [33] 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. [34]

Ecosystem Integration

While Solidity is deeply integrated with the Ethereum ecosystem and its numerous development tools, [35] 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.

Related Research Articles

A smart contract is a computer program or a 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 objectives of smart contracts are the reduction of need for trusted intermediators, arbitration costs, and fraud losses, as well as the reduction of malicious and accidental exceptions. Smart contracts are commonly associated with cryptocurrencies, and the smart contracts introduced by Ethereum are generally considered a fundamental building block for decentralized finance (DeFi) and non-fungible token (NFT) applications.

<span class="mw-page-title-main">JEB decompiler</span> Reverse engineering software

JEB is a disassembler and decompiler software for Android applications and native machine code. It decompiles Dalvik bytecode to Java source code, and x86, ARM, MIPS, RISC-V machine code to C source code. The assembly and source outputs are interactive and can be refactored. Users can also write their own scripts and plugins to extend JEB functionality.

<span class="mw-page-title-main">Ethereum</span> Open-source blockchain computing platform

Ethereum is a decentralized blockchain with smart contract functionality. Ether is the native cryptocurrency of the platform. Among cryptocurrencies, ether is second only to bitcoin in market capitalization. It is open-source software.

A decentralized autonomous organization (DAO), sometimes called a decentralized autonomous corporation (DAC), is an organization managed in whole or in part by decentralized computer program, with voting and finances handled through a blockchain. In general terms, DAOs are member-owned communities without centralized leadership. The precise legal status of this type of business organization is unclear.

<span class="mw-page-title-main">Counterparty (platform)</span> Cryptocurrency platform

Counterparty is a peer-to-peer financial platform and a distributed, open source protocol built on top of the Bitcoin blockchain and network. It was one of the most well-known "Bitcoin 2.0" platforms in 2014, along with Mastercoin, Ethereum, Colored Coins, Ripple and BitShares.

A 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. Since each block contains information about the previous block, they effectively form a chain, with each additional block linking to the ones before it. Consequently, blockchain transactions are irreversible in that, once they are recorded, the data in any given block cannot be altered retroactively without altering all subsequent blocks.

Hyperledger is an umbrella project of open source blockchains and related tools that the Linux Foundation started in December 2015. IBM, Intel, and SAP Ariba have contributed to support the collaborative development of blockchain-based distributed ledgers. It was renamed the Hyperledger Foundation in October 2021.

<span class="mw-page-title-main">The DAO</span> Early decentralized business based on the Ethereum blockchain

The DAO was a digital decentralized autonomous organization and a form of investor-directed venture capital fund. After launching in April 2016 via a token sale, it became one of the largest crowdfunding campaigns in history, but it ceased activity after much of its funds were taken in a hack in June 2016.

A decentralised application is an application that can operate autonomously, typically through the use of smart contracts, that run on a decentralized computing, blockchain or other distributed ledger system. Like traditional applications, DApps provide some function or utility to its users. However, unlike traditional applications, DApps operate without human intervention and are not owned by any one entity, rather DApps distribute tokens that represent ownership. These tokens are distributed according to a programmed algorithm to the users of the system, diluting ownership and control of the DApp. Without any one entity controlling the system, the application is therefore decentralised.

<span class="mw-page-title-main">Ethereum Classic</span> Blockchain computing platform

Ethereum Classic is a blockchain-based distributed computing platform that offers smart contract (scripting) functionality. It is open source and supports a modified version of Nakamoto consensus via transaction-based state transitions executed on a public Ethereum Virtual Machine (EVM).

<span class="mw-page-title-main">Firo (cryptocurrency)</span> Cryptocurrency

Firo, formerly known as Zcoin, is a cryptocurrency aimed at using cryptography to provide better privacy for its users compared to other cryptocurrencies such as Bitcoin.

<span class="mw-page-title-main">Cardano (blockchain platform)</span> Public blockchain platform

Cardano is a public blockchain platform. It is open-source and decentralized, with consensus achieved using proof of stake. It can facilitate peer-to-peer transactions with its internal cryptocurrency, ADA.

<span class="mw-page-title-main">Gavin Wood</span> British computer programmer and entrepreneur

Gavin James Wood is an English computer scientist, a co-founder of Ethereum, and creator of Polkadot and Kusama.

<span class="mw-page-title-main">The Open Network</span> Blockchain network originally developed by Telegram

The Open Network is a decentralized computer network consisting of a layer-1 blockchain with various components. TON was originally developed by Nikolai Durov who is also known for his role in creating the messaging platform, Telegram. Telegram had planned to use TON to launch its own cryptocurrency (Gram), but was forced to abandon the project in 2020 following an injunction by US regulators. The network was then renamed and independent developers have created their own cryptocurrencies and applications using TON. Toncoin, the principal token of The Open Network is deeply integrated into the Telegram messaging app, used for paying rewards to creators and developers, buying Telegram ads, hosting giveaways or purchasing services such as Telegram Premium.

<span class="mw-page-title-main">Tron (blockchain)</span> Blockchain computing platform

Tron is a decentralized, proof-of-stake blockchain with smart contract functionality. The cryptocurrency native to the blockchain is known as Tronix (TRX). It was founded in March 2014 by Justin Sun and since 2017 has been overseen and supervised by the TRON Foundation, a non-profit organization in Singapore, established in the same year. It is open-source software.

Decentralized finance provides financial instruments and services through smart contracts on a programmable, permissionless blockchain. This approach reduces the need for intermediaries such as brokerages, exchanges, or banks. DeFi platforms enable users to lend or borrow funds, speculate on asset price movements using derivatives, trade cryptocurrencies, insure against risks, and earn interest in savings-like accounts. The DeFi ecosystem is built on a layered architecture and highly composable building blocks. While some applications offer high interest rates, they carry high risks. Coding errors and hacks are a common challenge in DeFi.

Originally developed in 2019 by Microsoft under the name Coco and later rebranded to Confidential Consortium Framework (CCF), it is an open-source framework for developing of a new category of performant applications that focuses on the optimization of secure multi-party computation and data availability. Intended to accelerate the adoption of blockchain technology by enterprises, CCF can enable a variety of high-scale, confidential, permissioned distributed ledger networks that meet key enterprise requirements.

<span class="mw-page-title-main">Uniswap</span> Decentralized cryptocurrency exchange

Uniswap is a Ethereum-based decentralized cryptocurrency exchange (DEX) that uses a set of blockchain-based smart contracts to create liquidity pools for the execution of trades. It is an open source project and falls into the category of a DeFi product because it uses smart contracts to facilitate trades instead of a centralized exchange. The protocol facilitates automated transactions between cryptocurrency tokens on the Ethereum blockchain through the use of smart contracts. As of December 2024, Uniswap is estimated to be the largest decentralized exchange and the seven-largest cryptocurrency exchange overall by daily trading volume.

<span class="mw-page-title-main">Solana (blockchain platform)</span> Public blockchain platform

Solana is a blockchain platform which uses a proof-of-stake mechanism to provide smart contract functionality. Its native cryptocurrency is SOL.

<span class="mw-page-title-main">Tornado Cash</span> Virtual currency mixer on the Ethereum blockchain

Tornado Cash is an open source, non-custodial, fully decentralized cryptocurrency tumbler that runs on Ethereum Virtual Machine-compatible networks. It offers a service that mixes potentially identifiable or "tainted" cryptocurrency funds with others, so as to obscure the trail back to the fund's original source. This is a privacy tool used in EVM networks where all transactions are public by default.

References

  1. "Contributors to ethereum/solidity". GitHub. Retrieved 30 March 2023.
  2. "Contributors to ethereum/solidity". GitHub. Retrieved 30 March 2023.
  3. "Release 0.8.28". 9 October 2024. Retrieved 27 October 2024.
  4. "Build software better, together". GitHub. Retrieved 30 March 2023.
  5. The Solidity Contract-Oriented Programming Language, ethereum, 30 March 2023, retrieved 30 March 2023
  6. Afshar, Vala (17 July 2017). "Ethereum Is The Second Most Valuable Digital Currency, Behind Bitcoin". HuffPost. Retrieved 10 April 2019.
  7. "SOFE Berlin: Swift unveils blockchain proof-of-concept". Finextra (News). 24 November 2016. Retrieved 24 November 2016.
  8. Finley, Klint. "Someone Just Stole $50 Million from the Biggest Crowdfunded Project Ever. (Humans Can't Be Trusted)". Wired.
  9. The Solidity Contract-Oriented Programming Language, ethereum, 30 March 2023, retrieved 30 March 2023
  10. Wood, Gavin (13 January 2015). "Created Solidity". Ethereum Wiki (Archived). Retrieved 23 March 2024.
  11. "List of contributors". GitHub .
  12. College, A. M. C. (1 November 2022). Blockchain & Cryptocurrency Technology with Solidity Level 1. Advanced Micro Systems Sdn Bhd.
  13. "Gavin Wood". gavwood.com. Archived from the original on 30 March 2023. Retrieved 30 March 2023.
  14. Nikolic, Ivica; Kolluri, Aashish; Sergey, Ilya; Saxena, Prateek; Hobor, Aquinas (14 March 2018). "Finding The Greedy, Prodigal, and Suicidal Contracts at Scale". arXiv: 1802.06038 [cs.CR]. Different source languages compile to the EVM semantics, the predominant of them being Solidity
  15. "Westpac joins SWIFT's blockchain proof of concept". ZDNet. Retrieved 13 July 2022.
  16. "Hyperledger Fabric Tutorial - Create a blockchain app for loyalty points". IBM Developer. Retrieved 10 April 2019.
  17. "Language Influences — Solidity 0.8.17 documentation". docs.soliditylang.org. Retrieved 30 March 2023.
  18. Kapetanios-2008-06-27, p. 309.
  19. ethereum. "Ethereum Natural Specification Format". GitHub.
  20. "Introduction to Smart Contracts — Solidity 0.8.19 documentation". docs.soliditylang.org. Retrieved 30 March 2023.
  21. Schneier, Karthikeyan; Schneier, Antoine; Bhargavan, Cedric; Delignat-Lavaud, Anitha; Fournet, Gollamudi; Schneier, Bruce; Rastogi, Nadim; Sibut-Pinote, Aseem; Rastogi1, Thomas; Swamy, Nikhil; Zanella-Beguelin, Santiago (27 August 2016). "Short Paper: Formal Verification of Smart Contracts" (PDF). Microsoft Research, French Institute for Research in Computer Science and Automation, Harvard University. Archived (PDF) from the original on 27 August 2016.{{cite journal}}: CS1 maint: numeric names: authors list (link)
  22. "Remix - Ethereum IDE". remix.ethereum.org. Retrieved 30 March 2023.
  23. "EthFiddle - Solidity in the Browser. Powered By Loom Network". ethfiddle.com. Retrieved 30 March 2023.
  24. "solidity - Visual Studio Marketplace". marketplace.visualstudio.com. Retrieved 30 March 2023.
  25. "Solidity - IntelliJ IDEs Plugin | Marketplace". JetBrains Marketplace. Retrieved 30 March 2023.
  26. "Binance Smart Chain". GitHub . 26 October 2021.
  27. Vigna, Michael J. Casey and Paul (12 November 2014). "BitBeat: Bitcoin 2.0 Firm Counterparty Adopts Ethereum's Software". Wall Street Journal. ISSN   0099-9660 . Retrieved 16 April 2021.
  28. Swan, Melanie (2015). Blockchain : blueprint for a new economy (1st. ed.). [Sebastopol, Calif.] ISBN   978-1-4919-2047-3. OCLC   900781291.{{cite book}}: CS1 maint: location missing publisher (link)
  29. Tsankov, Petar; Dan, Andrei; Drachsler-Cohen, Dana; Gervais, Arthur; Bünzli, Florian; Vechev, Martin (15 October 2018). "Securify: Practical Security Analysis of Smart Contracts". Proceedings of the 2018 ACM SIGSAC Conference on Computer and Communications Security. Association for Computing Machinery. pp. 67–82. arXiv: 1806.01143 . doi:10.1145/3243734.3243780. hdl:10044/1/87935. ISBN   978-1-4503-5693-0. S2CID   46936025.
  30. Atzei, Nicola; Bartoletti, M.; Cimoli, Tiziana (2017). "A Survey of Attacks on Ethereum Smart Contracts (SoK)". Principles of Security and Trust, 6th International Conference, 2017, Proceedings. Lecture Notes in Computer Science. pp. 164–186. doi:10.1007/978-3-662-54455-6_8. ISBN   978-3-662-54454-9. S2CID   15494854.
  31. Finley, Klint (18 June 2016). "A $50 Million Hack Just Showed That the DAO Was All Too Human". Wired (News). Retrieved 18 February 2017.
  32. Zheng, Gavin; Gao, Longxiang; Huang, Liqun; Guan, Jian (31 August 2020). Ethereum Smart Contract Development in Solidity. Springer Nature. ISBN   978-981-15-6218-1.
  33. "Developing with Rust | Solana". solana.com. Retrieved 16 August 2024.
  34. "Rust Official Documentation".
  35. "Solidity Lang".