mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6566 from ethereum/docs-intro-sc-storage
[DOCS] Polish introductory section of introduction to smart contracts
This commit is contained in:
commit
09f46b98ca
@ -31,10 +31,9 @@ Storage Example
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
The first line simply tells that the source code is written for
|
The first line tells you that the source code is written for
|
||||||
Solidity version 0.4.0 or anything newer that does not break functionality
|
Solidity version 0.4.0, or a newer version of the language up to, but not including version 0.7.0.
|
||||||
(up to, but not including, version 0.7.0). This is to ensure that the
|
This is to ensure that the contract is not compilable with a new (breaking) compiler version, where it could behave differently.
|
||||||
contract is not compilable with a new (breaking) compiler version, where it could behave differently.
|
|
||||||
:ref:`Pragmas<pragma>` are common instructions for compilers about how to treat the
|
:ref:`Pragmas<pragma>` are common instructions for compilers about how to treat the
|
||||||
source code (e.g. `pragma once <https://en.wikipedia.org/wiki/Pragma_once>`_).
|
source code (e.g. `pragma once <https://en.wikipedia.org/wiki/Pragma_once>`_).
|
||||||
|
|
||||||
@ -42,9 +41,9 @@ A contract in the sense of Solidity is a collection of code (its *functions*) an
|
|||||||
data (its *state*) that resides at a specific address on the Ethereum
|
data (its *state*) that resides at a specific address on the Ethereum
|
||||||
blockchain. The line ``uint storedData;`` declares a state variable called ``storedData`` of
|
blockchain. The line ``uint storedData;`` declares a state variable called ``storedData`` of
|
||||||
type ``uint`` (*u*\nsigned *int*\eger of *256* bits). You can think of it as a single slot
|
type ``uint`` (*u*\nsigned *int*\eger of *256* bits). You can think of it as a single slot
|
||||||
in a database that can be queried and altered by calling functions of the
|
in a database that you can query and alter by calling functions of the
|
||||||
code that manages the database. In the case of Ethereum, this is always the owning
|
code that manages the database. In the case of Ethereum, this is always the owning
|
||||||
contract. And in this case, the functions ``set`` and ``get`` can be used to modify
|
contract. In this case, the functions ``set`` and ``get`` can be used to modify
|
||||||
or retrieve the value of the variable.
|
or retrieve the value of the variable.
|
||||||
|
|
||||||
To access a state variable, you do not need the prefix ``this.`` as is common in
|
To access a state variable, you do not need the prefix ``this.`` as is common in
|
||||||
@ -53,9 +52,9 @@ other languages.
|
|||||||
This contract does not do much yet apart from (due to the infrastructure
|
This contract does not do much yet apart from (due to the infrastructure
|
||||||
built by Ethereum) allowing anyone to store a single number that is accessible by
|
built by Ethereum) allowing anyone to store a single number that is accessible by
|
||||||
anyone in the world without a (feasible) way to prevent you from publishing
|
anyone in the world without a (feasible) way to prevent you from publishing
|
||||||
this number. Of course, anyone could just call ``set`` again with a different value
|
this number. Anyone could call ``set`` again with a different value
|
||||||
and overwrite your number, but the number will still be stored in the history
|
and overwrite your number, but the number is still stored in the history
|
||||||
of the blockchain. Later, we will see how you can impose access restrictions
|
of the blockchain. Later, you will see how you can impose access restrictions
|
||||||
so that only you can alter the number.
|
so that only you can alter the number.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
@ -64,7 +63,7 @@ so that only you can alter the number.
|
|||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
Be careful with using Unicode text, as similar looking (or even identical) characters can
|
Be careful with using Unicode text, as similar looking (or even identical) characters can
|
||||||
have different code points and as such will be encoded as a different byte array.
|
have different code points and as such are encoded as a different byte array.
|
||||||
|
|
||||||
.. index:: ! subcurrency
|
.. index:: ! subcurrency
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user