Solidity: quick notes on .transfer() vs .send()

…simply explained

Tesla 809
Tesla 809
May 3, 2018 · 1 min read

.transfer() vs .send() in Solidity: .send() and .transfer() are methods of the address data type. Their purpose is to transferring value between two addresses on the Ethereum Blockchain. Since, we are communicating with a distributed blockchain and writing to all nodes, it costs gas.

.send() was deprecated because it doesn’t throw an error when the action is not successful. It only returned False. This ends up costing gas without a refund and no state change. Developers were resorting to wrapping the method call in a require() function in order to deal with the issue.

The new .transfer() method fixed this issue and throws an error instead of a False. Although both do not allow for the customization of how much gas can be used (beyond the standard 21,000 gas), there is talk of upgrading .transfer() with this ability.

Tesla 809

Written by

Tesla 809

Developer, AI aficionado and math nerd. Organizer of New York Artificial Intelligence in Healthcare Meetup https://www.meetup.com/NYHAIS/