From a36e2ce0cbb7e1830e25dacd8d79f207c9bcca6a Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 8 Feb 2017 23:37:23 +0000 Subject: Document transfer() --- docs/control-structures.rst | 1 + docs/miscellaneous.rst | 5 +++-- docs/types.rst | 6 +++++- docs/units-and-global-variables.rst | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/control-structures.rst b/docs/control-structures.rst index df8ac729..ebc45965 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -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``. diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst index 3c57507e..7b0305d5 100644 --- a/docs/miscellaneous.rst +++ b/docs/miscellaneous.rst @@ -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 -- ``
.balance`` (``uint256``): balance of the address in Wei -- ``
.send(uint256 amount) returns (bool)``: send given amount of Wei to address, returns ``false`` on failure +- ``
.balance`` (``uint256``): balance of the :ref:`address` in Wei +- ``
.send(uint256 amount) returns (bool)``: send given amount of Wei to :ref:`address`, returns ``false`` on failure +- ``
.transfer(uint256 amount)``: send given amount of Wei to :ref:`address`, throws on failure .. index:: visibility, public, private, external, internal diff --git a/docs/types.rst b/docs/types.rst index 69c23e6e..342b67f4 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -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, diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst index 72741b67..49fe5d84 100644 --- a/docs/units-and-global-variables.rst +++ b/docs/units-and-global-variables.rst @@ -130,6 +130,8 @@ Address Related balance of the :ref:`address` in Wei ``
.send(uint256 amount) returns (bool)``: send given amount of Wei to :ref:`address`, returns ``false`` on failure +``
.transfer(uint256 amount)``: + send given amount of Wei to :ref:`address`, throws on failure For more information, see the section on :ref:`address`. -- cgit v1.2.3