mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Document transfer()
This commit is contained in:
parent
81006dae98
commit
a36e2ce0cb
@ -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 function without ``payable`` modifier (including the constructor and the fallback function).
|
||||||
#. If your contract receives Ether via a public getter function.
|
#. If your contract receives Ether via a public getter function.
|
||||||
#. If you call a zero-initialized variable of internal function type.
|
#. 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:
|
While a user-provided exception is generated in the following situations:
|
||||||
#. Calling ``throw``.
|
#. Calling ``throw``.
|
||||||
|
@ -465,8 +465,9 @@ Global Variables
|
|||||||
- ``this`` (current contract's type): the current contract, explicitly convertible to ``address``
|
- ``this`` (current contract's type): the current contract, explicitly convertible to ``address``
|
||||||
- ``super``: the contract one level higher in the inheritance hierarchy
|
- ``super``: the contract one level higher in the inheritance hierarchy
|
||||||
- ``selfdestruct(address recipient)``: destroy the current contract, sending its funds to the given address
|
- ``selfdestruct(address recipient)``: destroy the current contract, sending its funds to the given address
|
||||||
- ``<address>.balance`` (``uint256``): balance of the address in Wei
|
- ``<address>.balance`` (``uint256``): balance of the :ref:`address` in Wei
|
||||||
- ``<address>.send(uint256 amount) returns (bool)``: send given amount of Wei to address, returns ``false`` on failure
|
- ``<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
|
.. index:: visibility, public, private, external, internal
|
||||||
|
|
||||||
|
@ -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
|
equivalent to ``x / 2**y``. This means that shifting negative numbers
|
||||||
sign extends. Shifting by a negative amount throws a runtime exception.
|
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:
|
.. _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:
|
to make safe Ether transfers, always check the return value of ``send`` or even better:
|
||||||
Use a pattern where the recipient withdraws the money.
|
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``
|
* ``call``, ``callcode`` and ``delegatecall``
|
||||||
|
|
||||||
Furthermore, to interface with contracts that do not adhere to the ABI,
|
Furthermore, to interface with contracts that do not adhere to the ABI,
|
||||||
|
@ -130,6 +130,8 @@ Address Related
|
|||||||
balance of the :ref:`address` in Wei
|
balance of the :ref:`address` in Wei
|
||||||
``<address>.send(uint256 amount) returns (bool)``:
|
``<address>.send(uint256 amount) returns (bool)``:
|
||||||
send given amount of Wei to :ref:`address`, returns ``false`` on failure
|
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`.
|
For more information, see the section on :ref:`address`.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user