2015-12-10 10:35:54 +00:00
|
|
|
Solidity
|
|
|
|
========
|
2015-12-07 20:16:25 +00:00
|
|
|
|
2017-06-05 10:25:48 +00:00
|
|
|
.. image:: logo.svg
|
|
|
|
:width: 120px
|
|
|
|
:alt: Solidity logo
|
|
|
|
:align: center
|
|
|
|
|
2018-09-17 13:21:33 +00:00
|
|
|
Solidity is an object-oriented, high-level language for implementing smart
|
|
|
|
contracts. Smart contracts are programs which govern the behaviour of accounts
|
|
|
|
within the Ethereum state.
|
|
|
|
|
2021-03-01 18:15:30 +00:00
|
|
|
Solidity is a `curly-bracket language <https://en.wikipedia.org/wiki/List_of_programming_languages_by_type#Curly-bracket_languages>`_.
|
|
|
|
It is influenced by C++, Python and JavaScript, and is designed to target the Ethereum Virtual Machine (EVM).
|
2021-03-31 10:13:07 +00:00
|
|
|
You can find more details about which languages Solidity has been inspired by in
|
|
|
|
the :doc:`language influences <language-influences>` section.
|
2016-10-14 10:09:51 +00:00
|
|
|
|
|
|
|
Solidity is statically typed, supports inheritance, libraries and complex
|
2016-10-26 17:23:53 +00:00
|
|
|
user-defined types among other features.
|
2016-10-14 10:09:51 +00:00
|
|
|
|
2018-09-17 13:21:33 +00:00
|
|
|
With Solidity you can create contracts for uses such as voting, crowdfunding, blind auctions,
|
|
|
|
and multi-signature wallets.
|
2015-12-07 20:16:25 +00:00
|
|
|
|
2019-12-12 14:15:32 +00:00
|
|
|
When deploying contracts, you should use the latest released
|
|
|
|
version of Solidity. This is because breaking changes as well as
|
|
|
|
new features and bug fixes are introduced regularly. We currently use
|
|
|
|
a 0.x version number `to indicate this fast pace of change <https://semver.org/#spec-item-4>`_.
|
2019-01-07 21:29:36 +00:00
|
|
|
|
2019-04-03 15:37:35 +00:00
|
|
|
.. warning::
|
|
|
|
|
2020-12-15 14:24:01 +00:00
|
|
|
Solidity recently released the 0.8.x version that introduced a lot of breaking
|
|
|
|
changes. Make sure you read :doc:`the full list <080-breaking-changes>`.
|
2019-04-03 15:37:35 +00:00
|
|
|
|
2020-10-06 16:01:50 +00:00
|
|
|
Ideas for improving Solidity or this documentation are always welcome,
|
|
|
|
read our :doc:`contributors guide <contributing>` for more details.
|
|
|
|
|
|
|
|
Getting Started
|
|
|
|
---------------
|
|
|
|
|
|
|
|
**1. Understand the Smart Contract Basics**
|
|
|
|
|
|
|
|
If you are new to the concept of smart contracts we recommend you to get started by digging
|
|
|
|
into the "Introduction to Smart Contracts" section, which covers:
|
2020-11-23 09:32:09 +00:00
|
|
|
|
2020-10-06 16:01:50 +00:00
|
|
|
* :ref:`A simple example smart contract <simple-smart-contract>` written in Solidity.
|
|
|
|
* :ref:`Blockchain Basics <blockchain-basics>`.
|
|
|
|
* :ref:`The Ethereum Virtual Machine <the-ethereum-virtual-machine>`.
|
|
|
|
|
|
|
|
**2. Get to Know Solidity**
|
2018-09-17 15:16:05 +00:00
|
|
|
|
2020-10-06 16:01:50 +00:00
|
|
|
Once you are accustomed to the basics, we recommend you read the :doc:`"Solidity by Example" <solidity-by-example>`
|
|
|
|
and “Language Description” sections to understand the core concepts of the language.
|
2018-09-17 15:16:05 +00:00
|
|
|
|
2020-10-06 16:01:50 +00:00
|
|
|
**3. Install the Solidity Compiler**
|
|
|
|
|
|
|
|
There are various ways to install the Solidity compiler,
|
|
|
|
simply choose your preferred option and follow the steps outlined on the :ref:`installation page <installing-solidity>`.
|
2018-09-17 15:16:05 +00:00
|
|
|
|
|
|
|
.. hint::
|
2020-10-06 16:01:50 +00:00
|
|
|
You can try out code examples directly in your browser with the
|
2018-09-17 15:16:05 +00:00
|
|
|
`Remix IDE <https://remix.ethereum.org>`_. Remix is a web browser based IDE
|
2020-10-06 16:01:50 +00:00
|
|
|
that allows you to write, deploy and administer Solidity smart contracts, without
|
|
|
|
the need to install Solidity locally.
|
2015-12-10 10:35:54 +00:00
|
|
|
|
2018-02-01 16:13:46 +00:00
|
|
|
.. warning::
|
2018-09-17 15:16:05 +00:00
|
|
|
As humans write software, it can have bugs. You should follow established
|
2020-10-06 16:01:50 +00:00
|
|
|
software development best-practices when writing your smart contracts. This
|
2018-09-17 15:16:05 +00:00
|
|
|
includes code review, testing, audits, and correctness proofs. Smart contract
|
|
|
|
users are sometimes more confident with code than their authors, and
|
|
|
|
blockchains and smart contracts have their own unique issues to
|
|
|
|
watch out for, so before working on production code, make sure you read the
|
|
|
|
:ref:`security_considerations` section.
|
|
|
|
|
2020-10-06 16:01:50 +00:00
|
|
|
**4. Learn More**
|
2018-09-17 15:16:05 +00:00
|
|
|
|
2020-10-06 16:01:50 +00:00
|
|
|
If you want to learn more about building decentralized applications on Ethereum, the
|
|
|
|
`Ethereum Developer Resources <https://ethereum.org/en/developers/>`_
|
|
|
|
can help you with further general documentation around Ethereum, and a wide selection of tutorials,
|
|
|
|
tools and development frameworks.
|
|
|
|
|
|
|
|
If you have any questions, you can try searching for answers or asking on the
|
|
|
|
`Ethereum StackExchange <https://ethereum.stackexchange.com/>`_, or
|
|
|
|
our `Gitter channel <https://gitter.im/ethereum/solidity/>`_.
|
2018-02-01 16:13:46 +00:00
|
|
|
|
2018-11-12 10:46:23 +00:00
|
|
|
.. _translations:
|
|
|
|
|
2017-11-21 12:03:47 +00:00
|
|
|
Translations
|
|
|
|
------------
|
|
|
|
|
2018-09-17 15:16:05 +00:00
|
|
|
Community volunteers help translate this documentation into several languages.
|
|
|
|
They have varying degrees of completeness and up-to-dateness. The English
|
|
|
|
version stands as a reference.
|
2017-11-21 12:03:47 +00:00
|
|
|
|
2021-05-04 14:04:43 +00:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
We recently set up a new GitHub organization and translation workflow to help streamline the
|
|
|
|
community efforts. Please refer to the `translation guide <https://github.com/solidity-docs/translation-guide>`_
|
|
|
|
for information on how to contribute to the community translations moving forward.
|
|
|
|
|
2020-08-06 12:39:34 +00:00
|
|
|
* `French <https://solidity-fr.readthedocs.io>`_ (in progress)
|
2019-12-03 09:02:55 +00:00
|
|
|
* `Italian <https://github.com/damianoazzolini/solidity>`_ (in progress)
|
2019-07-15 08:49:03 +00:00
|
|
|
* `Japanese <https://solidity-jp.readthedocs.io>`_
|
2020-08-06 12:39:34 +00:00
|
|
|
* `Korean <https://solidity-kr.readthedocs.io>`_ (in progress)
|
2019-07-15 08:49:03 +00:00
|
|
|
* `Russian <https://github.com/ethereum/wiki/wiki/%5BRussian%5D-%D0%A0%D1%83%D0%BA%D0%BE%D0%B2%D0%BE%D0%B4%D1%81%D1%82%D0%B2%D0%BE-%D0%BF%D0%BE-Solidity>`_ (rather outdated)
|
2020-07-21 08:28:13 +00:00
|
|
|
* `Simplified Chinese <https://learnblockchain.cn/docs/solidity/>`_ (in progress)
|
2017-11-21 12:03:47 +00:00
|
|
|
* `Spanish <https://solidity-es.readthedocs.io>`_
|
2019-04-23 03:15:39 +00:00
|
|
|
* `Turkish <https://github.com/denizozzgur/Solidity_TR/blob/master/README.md>`_ (partial)
|
2017-11-21 12:03:47 +00:00
|
|
|
|
2015-12-07 20:16:25 +00:00
|
|
|
Contents
|
|
|
|
========
|
|
|
|
|
2015-12-10 10:35:54 +00:00
|
|
|
:ref:`Keyword Index <genindex>`, :ref:`Search Page <search>`
|
|
|
|
|
2015-12-07 20:16:25 +00:00
|
|
|
.. toctree::
|
|
|
|
:maxdepth: 2
|
2020-04-20 19:43:24 +00:00
|
|
|
:caption: Basics
|
2015-12-07 20:16:25 +00:00
|
|
|
|
|
|
|
introduction-to-smart-contracts.rst
|
2015-12-10 10:35:54 +00:00
|
|
|
installing-solidity.rst
|
2015-12-07 20:16:25 +00:00
|
|
|
solidity-by-example.rst
|
2020-04-20 19:43:24 +00:00
|
|
|
|
|
|
|
.. toctree::
|
|
|
|
:maxdepth: 2
|
|
|
|
:caption: Language Description
|
|
|
|
|
|
|
|
layout-of-source-files.rst
|
|
|
|
structure-of-a-contract.rst
|
|
|
|
types.rst
|
|
|
|
units-and-global-variables.rst
|
|
|
|
control-structures.rst
|
|
|
|
contracts.rst
|
|
|
|
assembly.rst
|
|
|
|
cheatsheet.rst
|
|
|
|
grammar.rst
|
|
|
|
|
2021-04-06 16:28:05 +00:00
|
|
|
.. toctree::
|
|
|
|
:maxdepth: 2
|
|
|
|
:caption: Compiler
|
|
|
|
|
|
|
|
using-the-compiler.rst
|
|
|
|
analysing-compilation-output.rst
|
|
|
|
|
2020-04-20 19:43:24 +00:00
|
|
|
.. toctree::
|
|
|
|
:maxdepth: 2
|
|
|
|
:caption: Internals
|
|
|
|
|
|
|
|
internals/layout_in_storage.rst
|
|
|
|
internals/layout_in_memory.rst
|
|
|
|
internals/layout_in_calldata.rst
|
|
|
|
internals/variable_cleanup.rst
|
|
|
|
internals/source_mappings.rst
|
2021-04-12 14:53:42 +00:00
|
|
|
internals/optimizer.rst
|
2020-04-20 19:43:24 +00:00
|
|
|
metadata.rst
|
|
|
|
abi-spec.rst
|
|
|
|
|
|
|
|
.. toctree::
|
|
|
|
:maxdepth: 2
|
|
|
|
:caption: Additional Material
|
|
|
|
|
|
|
|
050-breaking-changes.rst
|
|
|
|
060-breaking-changes.rst
|
2020-04-30 08:05:29 +00:00
|
|
|
070-breaking-changes.rst
|
2020-09-23 10:29:00 +00:00
|
|
|
080-breaking-changes.rst
|
2019-02-27 03:34:33 +00:00
|
|
|
natspec-format.rst
|
2016-06-28 15:29:08 +00:00
|
|
|
security-considerations.rst
|
2021-03-09 10:34:55 +00:00
|
|
|
smtchecker.rst
|
2018-10-17 13:54:35 +00:00
|
|
|
resources.rst
|
2018-06-05 17:43:23 +00:00
|
|
|
yul.rst
|
2015-12-07 20:16:25 +00:00
|
|
|
style-guide.rst
|
|
|
|
common-patterns.rst
|
2017-04-12 10:23:34 +00:00
|
|
|
bugs.rst
|
2016-08-29 17:24:28 +00:00
|
|
|
contributing.rst
|
2020-07-13 11:12:05 +00:00
|
|
|
brand-guide.rst
|
2021-03-31 10:13:07 +00:00
|
|
|
language-influences.rst
|