Skip to content

Commit 20c0707

Browse files
fixup! Update docs
1 parent 59b1704 commit 20c0707

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

docs/cheatsheet.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Members of ``address``
5959
.. warning::
6060
``send`` and ``transfer`` are deprecated and scheduled for removal in the next breaking version (0.9).
6161
Use the :ref:`call function <address_call_functions>` with an optionally provided maximum amount of
62-
gas (default forwards all remaining gas) and an empty calldata parameter, e.g., ``call{value: amount}("")``.
62+
gas (by default forwards 63/64 of the remaining gas) and an empty calldata parameter, e.g., ``call{value: amount}("")``.
6363

6464
.. index:: blockhash, blobhash, block, block;basefee, block;blobbasefee, block;chainid, block;coinbase, block;difficulty, block;gaslimit, block;number, block;prevrandao, block;timestamp
6565
.. index:: gasleft, msg;data, msg;sender, msg;sig, msg;value, tx;gasprice, tx;origin

docs/security-considerations.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Ether transfer can always include code execution,
7777
so the recipient could be a contract that calls back into ``withdraw``.
7878
This would let it get multiple refunds and, basically, retrieve all the Ether in the contract.
7979
In particular, the following contract will allow an attacker to refund multiple times
80-
as it uses ``call`` which forwards all remaining gas by default:
80+
as it uses ``call`` which forwards 63/64 of the remaining gas by default:
8181

8282
.. code-block:: solidity
8383

docs/types/value-types.rst

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ For a quick reference of all members of address, see :ref:`address_related`.
244244

245245
* ``balance`` and ``transfer``
246246

247-
It is possible to query the balance of an address using the property ``balance``
248-
and to send Ether (in units of wei) to a payable address using the ``transfer`` function:
247+
It is possible to query the balance of an address using the property ``balance``
248+
and to send Ether (in units of wei) to a payable address using the ``transfer`` function:
249249

250250
.. code-block:: solidity
251251
:force:
@@ -254,9 +254,9 @@ and to send Ether (in units of wei) to a payable address using the ``transfer``
254254
address myAddress = address(this);
255255
if (x.balance < 10 && myAddress.balance >= 10) x.transfer(10);
256256
257-
The ``transfer`` function fails if the balance of the current contract is not large enough
258-
or if the Ether transfer is rejected by the receiving account. The ``transfer`` function
259-
reverts on failure.
257+
The ``transfer`` function fails if the balance of the current contract is not large enough
258+
or if the Ether transfer is rejected by the receiving account. The ``transfer`` function
259+
reverts on failure.
260260
261261
.. note::
262262
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.
@@ -268,7 +268,7 @@ reverts on failure.
268268

269269
* ``send``
270270

271-
``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``.
271+
``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

273273
.. warning::
274274
There are some dangers in using ``send``: The transfer fails if the call stack depth is at 1024
@@ -285,16 +285,16 @@ reverts on failure.
285285

286286
* ``call``, ``delegatecall`` and ``staticcall``
287287

288-
In order to interface with contracts that do not adhere to the ABI,
289-
or to get more direct control over the encoding,
290-
the functions ``call``, ``delegatecall`` and ``staticcall`` are provided.
291-
They all take a single ``bytes memory`` parameter and
292-
return the success condition (as a ``bool``) and the returned data
293-
(``bytes memory``).
294-
The functions ``abi.encode``, ``abi.encodePacked``, ``abi.encodeWithSelector``
295-
and ``abi.encodeWithSignature`` can be used to encode structured data.
288+
In order to interface with contracts that do not adhere to the ABI,
289+
or to get more direct control over the encoding,
290+
the functions ``call``, ``delegatecall`` and ``staticcall`` are provided.
291+
They all take a single ``bytes memory`` parameter and
292+
return the success condition (as a ``bool``) and the returned data
293+
(``bytes memory``).
294+
The functions ``abi.encode``, ``abi.encodePacked``, ``abi.encodeWithSelector``
295+
and ``abi.encodeWithSignature`` can be used to encode structured data.
296296

297-
Example:
297+
Example:
298298

299299
.. code-block:: solidity
300300
@@ -315,35 +315,35 @@ Example:
315315
arbitrary arguments and would also handle a first argument of type
316316
``bytes4`` differently. These edge cases were removed in version 0.5.0.
317317

318-
It is possible to adjust the supplied gas with the ``gas`` modifier:
318+
It is possible to adjust the supplied gas with the ``gas`` modifier:
319319

320320
.. code-block:: solidity
321321
322322
address(nameReg).call{gas: 1000000}(abi.encodeWithSignature("register(string)", "MyName"));
323323
324-
Similarly, the supplied Ether value can be controlled too:
324+
Similarly, the supplied Ether value can be controlled too:
325325
326326
.. code-block:: solidity
327327
328328
address(nameReg).call{value: 1 ether}(abi.encodeWithSignature("register(string)", "MyName"));
329329
330-
Lastly, these modifiers can be combined. Their order does not matter:
330+
Lastly, these modifiers can be combined. Their order does not matter:
331331
332332
.. code-block:: solidity
333333
334334
address(nameReg).call{gas: 1000000, value: 1 ether}(abi.encodeWithSignature("register(string)", "MyName"));
335335
336-
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.
336+
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
338338
.. note::
339339
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

348348
.. note::
349349
It is best to avoid relying on hardcoded gas values in your smart contract code,
@@ -352,9 +352,9 @@ on ``call``.
352352

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

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

359359
.. warning::
360360
The output of ``addr.codehash`` may be ``0`` if the account associated with ``addr`` is empty or non-existent

0 commit comments

Comments
 (0)