The transfer method

The transfer method is similar to the send method. It is responsible for sending Ether or wei to an address. However, the difference here is that transfer raises an exception in the case of execution failure, instead of returning false , and all changes are reverted. Take a look at the transfer method in the following screenshot:

The transfer method is preferred over the send method as it raises an exception in the event of an error, meaning exceptions are bubbled up in the stack and halt execution.

Get Solidity Programming Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.