diff options
author | bernard peh <bpeh777@gmail.com> | 2018-03-02 13:25:52 +0800 |
---|---|---|
committer | bernard peh <bpeh777@gmail.com> | 2018-03-02 13:25:52 +0800 |
commit | 2c086cb90b59116fc300f52c135c465c82db1b1e (patch) | |
tree | 32f73fc5958d1bc4323b36486c71b90a2d9558ba /docs/contracts.rst | |
parent | c9840c98f45e6fa9258ec4624219622f5f71c75c (diff) | |
download | dexon-solidity-2c086cb90b59116fc300f52c135c465c82db1b1e.tar dexon-solidity-2c086cb90b59116fc300f52c135c465c82db1b1e.tar.gz dexon-solidity-2c086cb90b59116fc300f52c135c465c82db1b1e.tar.bz2 dexon-solidity-2c086cb90b59116fc300f52c135c465c82db1b1e.tar.lz dexon-solidity-2c086cb90b59116fc300f52c135c465c82db1b1e.tar.xz dexon-solidity-2c086cb90b59116fc300f52c135c465c82db1b1e.tar.zst dexon-solidity-2c086cb90b59116fc300f52c135c465c82db1b1e.zip |
clarify 2300 gas stipend in fallback function section
Diffstat (limited to 'docs/contracts.rst')
-rw-r--r-- | docs/contracts.rst | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst index 967eb2c8..cfd5256a 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -523,16 +523,9 @@ Ether (without data). Additionally, in order to receive Ether, the fallback func must be marked ``payable``. If no such function exists, the contract cannot receive Ether through regular transactions. -In such a context, there is usually very little gas available to the function call (to be precise, 2300 gas), so it is important to make fallback functions as cheap as possible. Note that the gas required by a transaction (as opposed to an internal call) that invokes the fallback function is much higher, because each transaction charges an additional amount of 21000 gas or more for things like signature checking. +It is worth nothing that the "send" or "transfer" function only has a 2300 gas stipend. If the fallback function is called by another contract account using the send/transfer function (eg address.transfer(1 ether)), then the fallback function only has 2300 gas to spend, meaning that it cannot do much other than basic logging. -In particular, the following operations will consume more gas than the stipend provided to a fallback function: - -- Writing to storage -- Creating a contract -- Calling an external function which consumes a large amount of gas -- Sending Ether - -Please ensure you test your fallback function thoroughly to ensure the execution cost is less than 2300 gas before deploying a contract. +Like any function, the fallback function can execute complex operations as long as there is enough gas passed on to it. .. note:: Even though the fallback function cannot have arguments, one can still use ``msg.data`` to retrieve |