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.25 [3] / 14 March 2024;26 days ago (14 March 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.

Contents

History

Solidity was proposed in August 2014 by Gavin Wood [12] [ 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. [13] [14]

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

Solidity uses ECMAScript-like syntax which makes it familiar for existing web developers; [16] 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. [17] [18] [ non-primary source needed ]

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

// 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. [28] 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. [29]

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." [30]

The developers community often cites Solidity requiring much of third party interfaces and APIs, and its inability to create critical information intensive smart contracts.

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 NFT applications.

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

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.

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

Counterparty is a peer-to-peer financial platform and distributed, open source Internet 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">Joseph Lubin (entrepreneur)</span> Canadian-American blockchain developer (born 1964)

Joseph Lubin is a Canadian-American businessman. He has founded and co-founded several companies, including the Swiss-based EthSuisse, contributing heavily to Ethereum, the decentralized cryptocurrency platform. Lubin is the founder of ConsenSys, a Brooklyn-based software production studio.

<span class="mw-page-title-main">The DAO</span> Decentralized business model 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.

<i>CryptoKitties</i> 2017 blockchain game on Ethereum

CryptoKitties is a blockchain game developed by Canadian studio Dapper Labs. The game allows players to buy, sell, and create non-fungible tokens (NFTs) using on Ethereum. These NFTs represent virtual cats. The game's popularity in December 2017, congested the Ethereum network, causing it to reach an all-time high in the number of transactions and slowing it down significantly.

A blockchain is a shared database that records transactions between two parties in an immutable ledger. Blockchain documents and confirms pseudonymous ownership of all transactions in a verifiable and sustainable way. After a transaction is validated and cryptographically verified by other participants or nodes in the network, it is made into a "block" on the blockchain. A block contains information about the time the transaction occurred, previous transactions, and details about the transaction. Once recorded as a block, transactions are ordered chronologically and cannot be altered. This technology rose to popularity after the creation of Bitcoin, the first application of blockchain technology, which has since catalyzed other cryptocurrencies and applications.

Decentralized finance offers financial instruments without relying on intermediaries such as brokerages, exchanges, or banks by using smart contracts on a blockchain, mainly Ethereum. DeFi platforms allow people to lend or borrow funds from others, speculate on price movements on assets using derivatives, trade cryptocurrencies, insure against risks, and earn interest in savings-like accounts. DeFi uses a layered architecture and highly composable building blocks. Some applications promote high-interest rates but are subject to high risk. Coding errors and hacks have been common in DeFi.

In blockchain technology, a testnet is an instance of a blockchain powered by the same or a newer version of the underlying software, to be used for testing and experimentation without risk to real funds or the main chain. Testnet coins are separate and distinct from the official (mainnet) coins, don't have value, and can be obtained freely from faucets.

<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.

Nervos Network is a blockchain platform which consists of multiple blockchain layers that are designed for different functions. The foundational layer is known as the Common Knowledge Base, whilst the native cryptocurrency of this layer is called CKB. This foundational layer uses a proof-of-work consensus model. Smart contracts and decentralized applications can be deployed on any layer.

<span class="mw-page-title-main">ERC-721</span> A technical standard for NFTs

The ERC-721 Non-fungible Token Standard, is a technical framework, defining a set of rules and interfaces for creating and managing unique, non-fungible tokens (NFTs) on the Ethereum blockchain. ERC-721 is recognized for formalizing the concept of an NFT and establishing the foundation of the multi-billion dollar digital collectibles eco-system that emerged alongside its adoption. It is one of the most widely used NFT standards across use cases and has been utilized in various high profile projects.

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.25". 14 March 2024. Retrieved 25 March 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.{{cite web}}: Check |archive-url= value (help)CS1 maint: url-status (link)
  11. "List of contributors". GitHub .
  12. "Gavin Wood". gavwood.com. Retrieved 30 March 2023.
  13. 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
  14. "Westpac joins SWIFT's blockchain proof of concept". ZDNet. Retrieved 13 July 2022.
  15. "Hyperledger Fabric Tutorial - Create a blockchain app for loyalty points". IBM Developer. Retrieved 10 April 2019.
  16. "Language Influences — Solidity 0.8.17 documentation". docs.soliditylang.org. Retrieved 30 March 2023.
  17. Kapetanios-2008-06-27, p. 309.
  18. ethereum. "Ethereum Natural Specification Format". GitHub.
  19. "Introduction to Smart Contracts — Solidity 0.8.19 documentation". docs.soliditylang.org. Retrieved 30 March 2023.
  20. 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)
  21. "Remix - Ethereum IDE". remix.ethereum.org. Retrieved 30 March 2023.
  22. "EthFiddle - Solidity in the Browser. Powered By Loom Network". ethfiddle.com. Retrieved 30 March 2023.
  23. "solidity - Visual Studio Marketplace". marketplace.visualstudio.com. Retrieved 30 March 2023.
  24. "Solidity - IntelliJ IDEs Plugin | Marketplace". JetBrains Marketplace. Retrieved 30 March 2023.
  25. "Binance Smart Chain". GitHub . 26 October 2021.
  26. 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.
  27. 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)
  28. Tsankov, Petar; Dan, Andrei; Drachsler-Cohen, Dana; Gervais, Arthur; Bünzli, Florian; Vechev, Martin (15 October 2018). "Securify: Practical Security Analysis of Smart Contracts". CCS '18: Proceedings of the 2018 ACM SIGSAC Conference on Computer and Communications Security. Association for Computing Machinery: 67–82. arXiv: 1806.01143 . doi:10.1145/3243734.3243780. hdl:10044/1/87935. S2CID   46936025.
  29. 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.
  30. Finley, Klint (18 June 2016). "A $50 Million Hack Just Showed That the DAO Was All Too Human". Wired (News). Retrieved 18 February 2017.