Document transfer()

This commit is contained in:
Alex Beregszaszi 2017-02-08 23:37:23 +00:00
parent 81006dae98
commit a36e2ce0cb
4 changed files with 11 additions and 3 deletions

View File

@ -395,6 +395,7 @@ Currently, Solidity automatically generates a runtime exception in the following
#. If your contract receives Ether via a public function without ``payable`` modifier (including the constructor and the fallback function).
#. If your contract receives Ether via a public getter function.
#. If you call a zero-initialized variable of internal function type.
#. If a ``.transfer()`` fails.
While a user-provided exception is generated in the following situations:
#. Calling ``throw``.

View File

@ -465,8 +465,9 @@ Global Variables
- ``this`` (current contract's type): the current contract, explicitly convertible to ``address``
- ``super``: the contract one level higher in the inheritance hierarchy
- ``selfdestruct(address recipient)``: destroy the current contract, sending its funds to the given address
- ``<address>.balance`` (``uint256``): balance of the address in Wei
- ``<address>.send(uint256 amount) returns (bool)``: send given amount of Wei to address, returns ``false`` on failure
- ``<address>.balance`` (``uint256``): balance of the :ref:`address` in Wei
- ``<address>.send(uint256 amount) returns (bool)``: send given amount of Wei to :ref:`address`, returns ``false`` on failure
- ``<address>.transfer(uint256 amount)``: send given amount of Wei to :ref:`address`, throws on failure
.. index:: visibility, public, private, external, internal

View File

@ -64,7 +64,7 @@ expression ``x << y`` is equivalent to ``x * 2**y`` and ``x >> y`` is
equivalent to ``x / 2**y``. This means that shifting negative numbers
sign extends. Shifting by a negative amount throws a runtime exception.
.. index:: address, balance, send, call, callcode, delegatecall
.. index:: address, balance, send, call, callcode, delegatecall, transfer
.. _address:
@ -102,6 +102,10 @@ and to send Ether (in units of wei) to an address using the ``send`` function:
to make safe Ether transfers, always check the return value of ``send`` or even better:
Use a pattern where the recipient withdraws the money.
* ``transfer``
Transfer operates the same way as ``send``, with the exception that it will cause a exception if the transfer has failed.
* ``call``, ``callcode`` and ``delegatecall``
Furthermore, to interface with contracts that do not adhere to the ABI,

View File

@ -130,6 +130,8 @@ Address Related
balance of the :ref:`address` in Wei
``<address>.send(uint256 amount) returns (bool)``:
send given amount of Wei to :ref:`address`, returns ``false`` on failure
``<address>.transfer(uint256 amount)``:
send given amount of Wei to :ref:`address`, throws on failure
For more information, see the section on :ref:`address`.