diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-02-11 07:15:32 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-02-24 08:18:18 +0800 |
commit | c46c68dfd8a5a8d82c19335c20d2bfa3aa8dd9ec (patch) | |
tree | c656cb9f7a4ba86032ab68d31e0f686253e882c0 | |
parent | c674155e584d2a1d6a88c49485e281e2a12b85d0 (diff) | |
download | dexon-solidity-c46c68dfd8a5a8d82c19335c20d2bfa3aa8dd9ec.tar dexon-solidity-c46c68dfd8a5a8d82c19335c20d2bfa3aa8dd9ec.tar.gz dexon-solidity-c46c68dfd8a5a8d82c19335c20d2bfa3aa8dd9ec.tar.bz2 dexon-solidity-c46c68dfd8a5a8d82c19335c20d2bfa3aa8dd9ec.tar.lz dexon-solidity-c46c68dfd8a5a8d82c19335c20d2bfa3aa8dd9ec.tar.xz dexon-solidity-c46c68dfd8a5a8d82c19335c20d2bfa3aa8dd9ec.tar.zst dexon-solidity-c46c68dfd8a5a8d82c19335c20d2bfa3aa8dd9ec.zip |
Prefer .transfer() over .send() in the documentation
-rw-r--r-- | docs/types.rst | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/docs/types.rst b/docs/types.rst index 342b67f4..f7d1d54f 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -80,31 +80,31 @@ Operators: Members of Addresses ^^^^^^^^^^^^^^^^^^^^ -* ``balance`` and ``send`` +* ``balance`` and ``transfer`` For a quick reference, see :ref:`address_related`. It is possible to query the balance of an address using the property ``balance`` -and to send Ether (in units of wei) to an address using the ``send`` function: +and to send Ether (in units of wei) to an address using the ``transfer`` function: :: address x = 0x123; address myAddress = this; - if (x.balance < 10 && myAddress.balance >= 10) x.send(10); + if (x.balance < 10 && myAddress.balance >= 10) x.transfer(10); .. note:: - If ``x`` is a contract address, its code (more specifically: its fallback function, if present) will be executed together with the ``send`` call (this is a limitation 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. In this case, ``send`` returns ``false``. + If ``x`` is a contract address, its code (more specifically: its fallback function, if present) will be executed together with the ``transfer`` call (this is a limitation 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. + +* ``send`` + +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``. .. warning:: There are some dangers in using ``send``: The transfer fails if the call stack depth is at 1024 (this can always be forced by the caller) and it also fails if the recipient runs out of gas. So in order - 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. + to make safe Ether transfers, always check the return value of ``send``, use ``transfer`` or even better: + use a pattern where the recipient withdraws the money. * ``call``, ``callcode`` and ``delegatecall`` |