From 0ad646635f6970de266138d4bdb3f1970406adfb Mon Sep 17 00:00:00 2001 From: Chris Ward Date: Wed, 1 Aug 2018 13:32:26 +0200 Subject: Small clarifications around the 2300 gas stipend from transfer and send --- docs/common-patterns.rst | 2 +- docs/contracts.rst | 5 ++++- docs/security-considerations.rst | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/common-patterns.rst b/docs/common-patterns.rst index 7c38b0e7..bc8286b2 100644 --- a/docs/common-patterns.rst +++ b/docs/common-patterns.rst @@ -93,7 +93,7 @@ Notice that, in this example, an attacker could trap the contract into an unusable state by causing ``richest`` to be the address of a contract that has a fallback function which fails (e.g. by using ``revert()`` or by just -consuming more than the 2300 gas stipend). That way, +consuming more than the 2300 gas stipend transferred to them). That way, whenever ``transfer`` is called to deliver funds to the "poisoned" contract, it will fail and thus also ``becomeRichest`` will fail, with the contract being stuck forever. diff --git a/docs/contracts.rst b/docs/contracts.rst index e78c3ff7..0263bd4f 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -561,7 +561,10 @@ 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 the worst case, the fallback function can only rely on 2300 gas being available (for example when send or transfer is used), leaving not much room to perform other operations except basic logging. The following operations will consume more gas than the 2300 gas stipend: +In the worst case, the fallback function can only rely on 2300 gas being +available (for example when `send` or `transfer` is used), leaving little +room to perform other operations except basic logging. The following operations +will consume more gas than the 2300 gas stipend: - Writing to storage - Creating a contract diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst index b997466b..5bb3d81d 100644 --- a/docs/security-considerations.rst +++ b/docs/security-considerations.rst @@ -135,7 +135,7 @@ Sending and Receiving Ether - If a contract receives Ether (without a function being called), the fallback function is executed. If it does not have a fallback function, the Ether will be rejected (by throwing an exception). During the execution of the fallback function, the contract can only rely - on the "gas stipend" (2300 gas) being available to it at that time. This stipend is not enough to access storage in any way. + on the "gas stipend" it is passed (2300 gas) being available to it at that time. This stipend is not enough to access storage in any way. To be sure that your contract can receive Ether in that way, check the gas requirements of the fallback function (for example in the "details" section in Remix). -- cgit