0/5
_You can follow along with the video course from here._ ### Introduction This lesson explores three different methods of sending ETH from one account to another: `transfer`, `send`, and `call`. We will understand their differences, how each one works, and when to use one instead of another. ### Transfer The `transfer` function is the simplest way to send Ether to a recipient address: ```solidity payable(msg.sender).transfer(amount); // the current contract sends the Ether amount to the msg.sender ``` It's necessary to convert the recipient address to a **payable** address to allow it to receive Ether. This can be done by wrapping `msg.sender` with the `payable` keyword. However, `transfer` has a significant limitation. It can only use up to 2300 gas and it reverts any transaction that exceeds this gas limit, as illustrated by [Solidity by Example](https://solidity-by-example.org/sending-ether/). ### Send The `send` function is similar to `transfer`, but it differs in its behaviour: ```solidity bool success = payable(msg.sender).send(address(this).balance); require(success, "Send failed"); ``` Like `transfer`, `send` also has a gas limit of 2300. If the gas limit is reached, it will not revert the transaction but return a boolean value (`true` or `false`) to indicate the success or failure of the transaction. It is the developer's responsibility to handle failure correctly, and it's good practice to trigger a **revert** condition if the `send` returns `false`. ### Call The `call` function is flexible and powerful. It can be used to call any function **without requiring its ABI**. It does not have a gas limit, and like `send`, it returns a boolean value instead of reverting like `transfer`. ```solidity (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success, "Call failed"); ``` To send funds using the `call` function, we convert the address of the receiver to `payable` and add the value inside curly brackets before the parameters passed. The `call` function returns two variables: a boolean for success or failure, and a byte object which stores returned data if any. > 👀❗**IMPORTANT**:br > `call` is the recommended way of sending and receiving Ethereum or other blockchain native tokens. ### Conclusion In conclusion, _transfer_, _send_, and _call_ are three unique methods for transferring Ether in Solidity. They vary in their syntax, behaviour, and gas limits, each offering distinct advantages and drawbacks. ### 🧑💻 Test yourself 1. 📕 What are the primary differences between _transfer_, _send_, and _call_ when transferring Ether? 2. 📕 Why is it necessary to convert an address to a `payable` type before sending Ether to it? 3. 🧑💻 Implement a function `callAmountTo` using `call` to send Ether from the contract to an address provided as an argument. Ensure the function handles failures appropriately.
You can follow along with the video course from here.
This lesson explores three different methods of sending ETH from one account to another: transfer
, send
, and call
. We will understand their differences, how each one works, and when to use one instead of another.
The transfer
function is the simplest way to send Ether to a recipient address:
It's necessary to convert the recipient address to a payable address to allow it to receive Ether. This can be done by wrapping msg.sender
with the payable
keyword.
However, transfer
has a significant limitation. It can only use up to 2300 gas and it reverts any transaction that exceeds this gas limit, as illustrated by Solidity by Example.
The send
function is similar to transfer
, but it differs in its behaviour:
Like transfer
, send
also has a gas limit of 2300. If the gas limit is reached, it will not revert the transaction but return a boolean value (true
or false
) to indicate the success or failure of the transaction. It is the developer's responsibility to handle failure correctly, and it's good practice to trigger a revert condition if the send
returns false
.
The call
function is flexible and powerful. It can be used to call any function without requiring its ABI. It does not have a gas limit, and like send
, it returns a boolean value instead of reverting like transfer
.
To send funds using the call
function, we convert the address of the receiver to payable
and add the value inside curly brackets before the parameters passed.
The call
function returns two variables: a boolean for success or failure, and a byte object which stores returned data if any.
👀❗IMPORTANT:br
call
is the recommended way of sending and receiving Ethereum or other blockchain native tokens.
In conclusion, transfer, send, and call are three unique methods for transferring Ether in Solidity. They vary in their syntax, behaviour, and gas limits, each offering distinct advantages and drawbacks.
📕 What are the primary differences between transfer, send, and call when transferring Ether?
📕 Why is it necessary to convert an address to a payable
type before sending Ether to it?
🧑💻 Implement a function callAmountTo
using call
to send Ether from the contract to an address provided as an argument. Ensure the function handles failures appropriately.
An exploration of three methods for sending Ether from a contract in Solidity: transfer, send, and call. The lesson compares these methods, discussing their syntax, behavior, and appropriate use cases, with a focus on their gas usage and security implications.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Blockchain developer fundamentals
Smart contract ABI
Solidity Smart contract development
Solidity Safemath
Solidity custom errors
Solidity inheritance
Solidity gas optimization techniques
Solidity and Ethereum developer workflow
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Guest lecturers:
Last updated on July 22, 2025
Duration: 1h 46min
Duration: 38min
Duration: 2h
Duration: 23min
Course Overview
About the course
Blockchain developer fundamentals
Smart contract ABI
Solidity Smart contract development
Solidity Safemath
Solidity custom errors
Solidity inheritance
Solidity gas optimization techniques
Solidity and Ethereum developer workflow
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Guest lecturers:
Last updated on July 22, 2025