Skip to content

Commit d57fae4

Browse files
fixup! Update docs
1 parent ea1f185 commit d57fae4

File tree

2 files changed

+89
-60
lines changed

2 files changed

+89
-60
lines changed

docs/090-breaking-changes.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
********************************
2+
Solidity v0.5.0 Breaking Changes
3+
********************************
4+
5+
This section highlights the main breaking changes introduced in Solidity
6+
version 0.9.0, along with the reasoning behind the changes and how to update
7+
affected code.
8+
For the full list check
9+
`the release changelog <https://github.com/argotorg/solidity/releases/tag/v0.9.0>`_.
10+
11+
Changes to the Syntax
12+
=================
13+
14+
* The ``send`` and ``transfer`` member functions of ``address`` are deprecated and will be removed.
15+
They should be replaced by the :ref:`call function <address_related>` with an optionally provided maximum amount
16+
of gas (default forwards all remaining gas) and an empty calldata parameter, e.g., ``call{value: amount}("")``.
17+
18+
* The ABI coder v1 is deprecated and will be removed. Use ABI coder v2 instead.
19+
The old behavior will not be available anymore and using ``pragma abicoder v1;`` will result in a syntax error.
20+
21+
* ``virtual`` modifiers are deprecated and no longer available starting with v.0.9.0.
22+
23+
* The ``memory-safe-assembly`` special comment is deprecated and will be removed.
24+
For new code targeting recent compilers, specify the assembly block annotation.
25+
26+
* Comparison of variables of contract type is deprecated and will not be allowed anymore starting with v.0.9.0.
27+
28+
29+

docs/types/value-types.rst

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -247,39 +247,39 @@ For a quick reference of all members of address, see :ref:`address_related`.
247247
It is possible to query the balance of an address using the property ``balance``
248248
and to send Ether (in units of wei) to a payable address using the ``transfer`` function:
249249

250-
.. code-block:: solidity
251-
:force:
250+
.. code-block:: solidity
251+
:force:
252252
253-
address payable x = payable(0x123);
254-
address myAddress = address(this);
255-
if (x.balance < 10 && myAddress.balance >= 10) x.transfer(10);
253+
address payable x = payable(0x123);
254+
address myAddress = address(this);
255+
if (x.balance < 10 && myAddress.balance >= 10) x.transfer(10);
256256
257257
The ``transfer`` function fails if the balance of the current contract is not large enough
258258
or if the Ether transfer is rejected by the receiving account. The ``transfer`` function
259259
reverts on failure.
260260

261-
.. note::
262-
If ``x`` is a contract address, its code (more specifically: its :ref:`receive-ether-function`, if present, or otherwise its :ref:`fallback-function`, if present) will be executed together with the ``transfer`` call (this is a feature of the EVM and cannot be prevented). If that execution runs out of gas or fails in any way, the Ether transfer will be reverted and the current contract will stop with an exception.
261+
.. note::
262+
If ``x`` is a contract address, its code (more specifically: its :ref:`receive-ether-function`, if present, or otherwise its :ref:`fallback-function`, if present) will be executed together with the ``transfer`` call (this is a feature of the EVM and cannot be prevented). If that execution runs out of gas or fails in any way, the Ether transfer will be reverted and the current contract will stop with an exception.
263263

264-
.. warning::
265-
``transfer`` is deprecated and scheduled for removal in the next breaking version (0.9).
266-
Use the :ref:`call function <address_call_functions>` with an optionally provided maximum amount of
267-
gas (default forwards all remaining gas) and an empty calldata parameter, e.g., ``call{value: amount}("")``.
264+
.. warning::
265+
``transfer`` is deprecated and scheduled for removal in the next breaking version (0.9).
266+
Use the :ref:`call function <address_call_functions>` with an optionally provided maximum amount of
267+
gas (default forwards all remaining gas) and an empty calldata parameter, e.g., ``call{value: amount}("")``.
268268

269269
* ``send``
270270

271271
``send`` is the low-level counterpart of ``transfer``. If the execution fails, the current contract will not stop with an exception, but ``send`` will return ``false``.
272272

273-
.. warning::
274-
There are some dangers in using ``send``: The transfer fails if the call stack depth is at 1024
275-
(this can always be forced by the caller) and it also fails if the recipient runs out of gas. So in order
276-
to make safe Ether transfers, always check the return value of ``send``, use ``transfer`` or even better:
277-
use a pattern where the recipient withdraws the Ether.
273+
.. warning::
274+
There are some dangers in using ``send``: The transfer fails if the call stack depth is at 1024
275+
(this can always be forced by the caller) and it also fails if the recipient runs out of gas. So in order
276+
to make safe Ether transfers, always check the return value of ``send``, use ``transfer`` or even better:
277+
use a pattern where the recipient withdraws the Ether.
278278

279-
.. warning::
280-
``send`` is deprecated and scheduled for removal in the next breaking version (0.9).
281-
Use the :ref:`call function <address_call_functions>` with an optionally provided maximum amount of
282-
gas (default forwards all remaining gas) and an empty calldata parameter, e.g., ``call{value: amount}("")``.
279+
.. warning::
280+
``send`` is deprecated and scheduled for removal in the next breaking version (0.9).
281+
Use the :ref:`call function <address_call_functions>` with an optionally provided maximum amount of
282+
gas (default forwards all remaining gas) and an empty calldata parameter, e.g., ``call{value: amount}("")``.
283283

284284
.. _address_call_functions:
285285

@@ -296,76 +296,76 @@ For a quick reference of all members of address, see :ref:`address_related`.
296296

297297
Example:
298298

299-
.. code-block:: solidity
299+
.. code-block:: solidity
300300
301-
bytes memory payload = abi.encodeWithSignature("register(string)", "MyName");
302-
(bool success, bytes memory returnData) = address(nameReg).call(payload);
303-
require(success);
301+
bytes memory payload = abi.encodeWithSignature("register(string)", "MyName");
302+
(bool success, bytes memory returnData) = address(nameReg).call(payload);
303+
require(success);
304304
305-
.. warning::
306-
All these functions are low-level functions and should be used with care.
307-
Specifically, any unknown contract might be malicious and if you call it, you
308-
hand over control to that contract which could in turn call back into
309-
your contract, so be prepared for changes to your state variables
310-
when the call returns. The regular way to interact with other contracts
311-
is to call a function on a contract object (``x.f()``).
305+
.. warning::
306+
All these functions are low-level functions and should be used with care.
307+
Specifically, any unknown contract might be malicious and if you call it, you
308+
hand over control to that contract which could in turn call back into
309+
your contract, so be prepared for changes to your state variables
310+
when the call returns. The regular way to interact with other contracts
311+
is to call a function on a contract object (``x.f()``).
312312

313-
.. note::
314-
Previous versions of Solidity allowed these functions to receive
315-
arbitrary arguments and would also handle a first argument of type
316-
``bytes4`` differently. These edge cases were removed in version 0.5.0.
313+
.. note::
314+
Previous versions of Solidity allowed these functions to receive
315+
arbitrary arguments and would also handle a first argument of type
316+
``bytes4`` differently. These edge cases were removed in version 0.5.0.
317317

318318
It is possible to adjust the supplied gas with the ``gas`` modifier:
319319

320-
.. code-block:: solidity
320+
.. code-block:: solidity
321321
322-
address(nameReg).call{gas: 1000000}(abi.encodeWithSignature("register(string)", "MyName"));
322+
address(nameReg).call{gas: 1000000}(abi.encodeWithSignature("register(string)", "MyName"));
323323
324324
Similarly, the supplied Ether value can be controlled too:
325325

326-
.. code-block:: solidity
326+
.. code-block:: solidity
327327
328-
address(nameReg).call{value: 1 ether}(abi.encodeWithSignature("register(string)", "MyName"));
328+
address(nameReg).call{value: 1 ether}(abi.encodeWithSignature("register(string)", "MyName"));
329329
330330
Lastly, these modifiers can be combined. Their order does not matter:
331331

332-
.. code-block:: solidity
332+
.. code-block:: solidity
333333
334-
address(nameReg).call{gas: 1000000, value: 1 ether}(abi.encodeWithSignature("register(string)", "MyName"));
334+
address(nameReg).call{gas: 1000000, value: 1 ether}(abi.encodeWithSignature("register(string)", "MyName"));
335335
336336
In a similar way, the function ``delegatecall`` can be used: the difference is that only the code of the given address is used, all other aspects (storage, balance, ...) are taken from the current contract. The purpose of ``delegatecall`` is to use library code which is stored in another contract. The user has to ensure that the layout of storage in both contracts is suitable for delegatecall to be used.
337337

338-
.. note::
339-
Prior to homestead, only a limited variant called ``callcode`` was available that did not provide access to the original ``msg.sender`` and ``msg.value`` values. This function was removed in version 0.5.0.
338+
.. note::
339+
Prior to homestead, only a limited variant called ``callcode`` was available that did not provide access to the original ``msg.sender`` and ``msg.value`` values. This function was removed in version 0.5.0.
340340

341-
Since byzantium ``staticcall`` can be used as well. This is basically the same as ``call``, but will revert if the called function modifies the state in any way.
341+
Since byzantium ``staticcall`` can be used as well. This is basically the same as ``call``, but will revert if the called function modifies the state in any way.
342342

343-
All three functions ``call``, ``delegatecall`` and ``staticcall`` are very low-level functions and should only be used as a *last resort* as they break the type-safety of Solidity.
343+
All three functions ``call``, ``delegatecall`` and ``staticcall`` are very low-level functions and should only be used as a *last resort* as they break the type-safety of Solidity.
344344

345-
The ``gas`` option is available on all three methods, while the ``value`` option is only available
346-
on ``call``.
345+
The ``gas`` option is available on all three methods, while the ``value`` option is only available
346+
on ``call``.
347347

348-
.. note::
349-
It is best to avoid relying on hardcoded gas values in your smart contract code,
350-
regardless of whether state is read from or written to, as this can have many pitfalls.
351-
Also, access to gas might change in the future.
348+
.. note::
349+
It is best to avoid relying on hardcoded gas values in your smart contract code,
350+
regardless of whether state is read from or written to, as this can have many pitfalls.
351+
Also, access to gas might change in the future.
352352

353353
* ``code`` and ``codehash``
354354

355355
You can query the deployed code for any smart contract. Use ``.code`` to get the EVM bytecode as a
356356
``bytes memory``, which might be empty. Use ``.codehash`` to get the Keccak-256 hash of that code
357357
(as a ``bytes32``). Note that ``addr.codehash`` is cheaper than using ``keccak256(addr.code)``.
358358

359-
.. warning::
360-
The output of ``addr.codehash`` may be ``0`` if the account associated with ``addr`` is empty or non-existent
361-
(i.e., it has no code, zero balance, and zero nonce as defined by `EIP-161 <https://eips.ethereum.org/EIPS/eip-161>`_).
362-
If the account has no code but a non-zero balance or nonce, then ``addr.codehash`` will output the Keccak-256 hash of empty data
363-
(i.e., ``keccak256("")`` which is equal to ``c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470``), as defined by
364-
`EIP-1052 <https://eips.ethereum.org/EIPS/eip-1052>`_.
359+
.. warning::
360+
The output of ``addr.codehash`` may be ``0`` if the account associated with ``addr`` is empty or non-existent
361+
(i.e., it has no code, zero balance, and zero nonce as defined by `EIP-161 <https://eips.ethereum.org/EIPS/eip-161>`_).
362+
If the account has no code but a non-zero balance or nonce, then ``addr.codehash`` will output the Keccak-256 hash of empty data
363+
(i.e., ``keccak256("")`` which is equal to ``c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470``), as defined by
364+
`EIP-1052 <https://eips.ethereum.org/EIPS/eip-1052>`_.
365365

366-
.. note::
367-
All contracts can be converted to ``address`` type, so it is possible to query the balance of the
368-
current contract using ``address(this).balance``.
366+
.. note::
367+
All contracts can be converted to ``address`` type, so it is possible to query the balance of the
368+
current contract using ``address(this).balance``.
369369

370370
.. index:: ! contract type, ! type; contract
371371

0 commit comments

Comments
 (0)