Solidity

From HandWiki
Short description: Programming language
Solidity
Solidity logo.svg
The Solidity language logo
ParadigmObject-oriented
Designed byGavin Wood
DeveloperChristian Reitwiessner,[1] Alex Beregszaszi,[2] and several former Ethereum core contributors.
First appearedAugust 2014
Stable release
0.8.21 / July 19, 2023; 12 months ago (2023-07-19)
Implementation languageC++[3]
LicenseGNU General Public License v3.0[4]
Filename extensions.sol
Websitesoliditylang.org
Influenced by
JavaScript, C++, Python

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

History

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

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

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

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

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;

contract Coin {
    // The keyword "public" makes variables
    // accessible from other contracts
    address public minter;
    mapping(address => uint) public balances;

    // Events allow clients to react to specific
    // contract changes you declare
    event Sent(address from, address to, uint amount);

    // Constructor code is only run when the contract
    // is created
    constructor() {
        minter = msg.sender;
    }

    // Sends an amount of newly created coins to an address
    // Can only be called by the contract creator
    function mint(address receiver, uint amount) 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.
    error InsufficientBalance(uint requested, uint available);

    // Sends an amount of existing coins
    // from any caller to an address
    function send(address receiver, uint amount) public {
        if (amount > balances[msg.sender])
            revert InsufficientBalance({
                requested: amount,
                available: balances[msg.sender]
            });

        balances[msg.sender] -= amount;
        balances[receiver] += amount;
        emit Sent(msg.sender, receiver, amount);
    }
}

Development IDEs

Editor extensions

  • Solidity Support for Visual Studio Code[22]
  • Solidity Support For IntelliJ[23]

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

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

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

References

  1. "Contributors to ethereum/solidity" (in en). https://github.com/ethereum/solidity. 
  2. "Contributors to ethereum/solidity" (in en). https://github.com/ethereum/solidity. 
  3. "Build software better, together" (in en). https://github.com/. 
  4. The Solidity Contract-Oriented Programming Language, ethereum, 2023-03-30, https://github.com/ethereum/solidity/blob/bca3fb8ffd7c57a3f6920fd5a115a9a0fc0edb21/LICENSE.txt, retrieved 2023-03-30 
  5. Afshar, Vala (2017-07-17). "Ethereum Is The Second Most Valuable Digital Currency, Behind Bitcoin" (in en). https://www.huffpost.com/entry/ethereum-is-the-second-most-valuable-digital-currency_b_596bc5c7e4b022bb9372b2b2. 
  6. "SOFE Berlin: Swift unveils blockchain proof-of-concept". Finextra. 24 November 2016. https://www.finextra.com/newsarticle/29813/sofe-berlin-swift-unveils-blockchain-proof-of-concept. 
  7. Finley, Klint. "Someone Just Stole $50 Million from the Biggest Crowdfunded Project Ever. (Humans Can't Be Trusted)" (in en-us). Wired. https://www.wired.com/2016/06/50-million-hack-just-showed-dao-human/. 
  8. The Solidity Contract-Oriented Programming Language, ethereum, 2023-03-30, https://github.com/ethereum/solidity/blob/bca3fb8ffd7c57a3f6920fd5a115a9a0fc0edb21/LICENSE.txt, retrieved 2023-03-30 
  9. "Gavin Wood". https://gavwood.com/. 
  10. "List of contributors". https://github.com/ethereum/solidity/graphs/contributors. 
  11. "Gavin Wood". https://gavwood.com/. 
  12. 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
  13. "Westpac joins SWIFT's blockchain proof of concept" (in en). https://www.zdnet.com/article/westpac-joins-swifts-blockchain-proof-of-concept/. 
  14. "Hyperledger Fabric Tutorial - Create a blockchain app for loyalty points" (in en-US). https://developer.ibm.com/patterns/loyalty-points-fabric-evm/. 
  15. "Language Influences — Solidity 0.8.17 documentation". https://docs.soliditylang.org/en/v0.8.17/language-influences.html. 
  16. Kapetanios-2008-06-27, p. 309.
  17. ethereum. "Ethereum Natural Specification Format". GitHub. https://github.com/ethereum/wiki/wiki/Ethereum-Natural-Specification-Format. 
  18. "Introduction to Smart Contracts — Solidity 0.8.19 documentation". https://docs.soliditylang.org/en/v0.8.19/introduction-to-smart-contracts.html#subcurrency-example. 
  19. Schneier, Karthikeyan; Schneier, Antoine; Bhargavan, Cedric; Delignat-Lavaud, Anitha; Fournet, Gollamudi; Schneier, Bruce; Rastogi, Nadim; Sibut-Pinote, Aseem et al. (27 August 2016). "Short Paper: Formal Verification of Smart Contracts" (in en). Microsoft Research, French Institute for Research in Computer Science and Automation, Harvard University. http://research.microsoft.com/en-us/um/people/nswamy/papers/solidether.pdf. 
  20. "Remix - Ethereum IDE". https://remix.ethereum.org/. 
  21. "EthFiddle - Solidity in the Browser. Powered By Loom Network". https://ethfiddle.com/OGURL. 
  22. "solidity - Visual Studio Marketplace" (in en-us). https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity. 
  23. "Solidity - IntelliJ IDEs Plugin | Marketplace". https://plugins.jetbrains.com/plugin/9475-solidity. 
  24. "Binance Smart Chain". 26 October 2021. https://github.com/binance-chain/bsc. 
  25. Vigna, Michael J. Casey and Paul (2014-11-12). "BitBeat: Bitcoin 2.0 Firm Counterparty Adopts Ethereum's Software" (in en-US). Wall Street Journal. ISSN 0099-9660. https://blogs.wsj.com/moneybeat/2014/11/12/bitbeat-bitcoin-2-0-firm-counterparty-adopts-ethereums-software/. 
  26. Swan, Melanie (2015). Blockchain : blueprint for a new economy (1st. ed.). [Sebastopol, Calif.]. ISBN 978-1-4919-2047-3. OCLC 900781291. https://www.worldcat.org/oclc/900781291. 
  27. Tsankov, Petar; Dan, Andrei; Drachsler-Cohen, Dana; Gervais, Arthur; Bünzli, Florian; Vechev, Martin (15 October 2018). Securify: Practical Security Analysis of Smart Contracts. Association for Computing Machinery. pp. 67–82. doi:10.1145/3243734.3243780. 
  28. Atzei, Nicola; Bartoletti, M.; Cimoli, Tiziana (2017). "A Survey of Attacks on Ethereum Smart Contracts (SoK)". Principles of Security and Trust. Lecture Notes in Computer Science. 10204. 164–186. doi:10.1007/978-3-662-54455-6_8. ISBN 978-3-662-54454-9. 
  29. Finley, Klint (18 June 2016). "A $50 Million Hack Just Showed That the DAO Was All Too Human". Wired. https://www.wired.com/2016/06/50-million-hack-just-showed-dao-human/. Retrieved 18 February 2017.