1 Send()
does not forward gas anymore. It simply uses the hardcoded stipend (2300 gas) siphoned from the value transfer cost (minimum 9040). It's enough to send ether, but also enough to basically do one additional small logging operation (in a fallback function). 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
2 If a send()
call runs out of gas, it does not throw an error, it simply returns false.
from solidity Doc:
If a contract receives Ether (without a function being called), the
fallback function is executed. 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. 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
browser-solidity).
• There is a way to forward more gas to the receiving contract using
addr.call.value(x)(). This is essentially the same as addr.send(x), only that it forwards all remaining gas and opens up the ability for the recipient to perform more expensive actions.
This might include calling back into the sending contract or
other state changes you might not have though of. So it allows for
great flexibility for honest users but also for malicious actors.
Warning: Contracts that receive Ether but do not define a fallback function throw an exception, sending back
the Ether (this was different before Solidity v0.4.0). So if you want your contract to receive Ether, you have to
implement a fallback function.