A short notice on the two functions
Since version 0.4.13 (actually since this issue is resolved) Solidity has one new important function, the
transfer function. Here is the difference between .send and .transfer:
How send works (or worked)
address.send(amount) it was possible to send an amount to a specific address. There are two problems:
1. Only a small amount of gas is sent along (21,000 gas). So the receiver can only emit one single event at max, it can't be another contract that changes state variables or call again other contracts. So it's pretty "safe by accident".
2. If an error throw
.send will return false and not propagate the error.
.send(...) is now deprecated.
Workaround with call()()
Man developers therefore defaulted back to
recipient.call.value(x)(). Which was merely a workaround and still returns a boolean on success or error. Now exactly this workaround received a name and fully propagates exceptions.
With the new function transfer, you get two new things:
1. it fully propagates errors (on throw)
2. you can specify the amount of gas sent along.
The two options to use
Also the Solidity by Example Documentation got updated and now uses the
Did I miss something? Do you have opinions? Let me hear in the comments!