0
0
Blockchain / Solidityprogramming~10 mins

Sending Ether (transfer, send, call) in Blockchain / Solidity - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Sending Ether (transfer, send, call)
Start Transaction
Choose Method
transfer
Check success?
NoRevert or Handle
Yes
Complete Transaction
This flow shows how Ether is sent using transfer, send, or call, checking success and handling failure.
Execution Sample
Blockchain / Solidity
address payable recipient = payable(0x1234567890123456789012345678901234567890);
uint amount = 1 ether;

// Using transfer
recipient.transfer(amount);
This code sends 1 ether to recipient using transfer method.
Execution Table
StepMethodActionSuccess CheckResult
1transferSend 1 ether to recipientImplicit revert on failureTransaction succeeds or reverts
2sendSend 1 ether to recipientReturns bool successIf false, handle failure manually
3callSend 1 ether with call{value: amount}()Returns (bool success, bytes data)If false, handle failure manually
4send failuresend returns falseCheck success == falseHandle failure (e.g. revert or log)
5call failurecall returns falseCheck success == falseHandle failure (e.g. revert or log)
💡 Execution stops after sending Ether and handling success or failure.
Variable Tracker
VariableStartAfter transferAfter sendAfter call
recipient0x12345678901234567890123456789012345678900x12345678901234567890123456789012345678900x12345678901234567890123456789012345678900x1234567890123456789012345678901234567890
amount1 ether1 ether1 ether1 ether
successundefinedN/A (transfer reverts on fail)true or falsetrue or false
Key Moments - 3 Insights
Why does transfer not return a success value?
transfer automatically reverts the transaction if sending Ether fails, so no success boolean is returned (see execution_table row 1).
What should I do if send returns false?
You must check the boolean returned by send and handle failure manually, like reverting or logging (see execution_table row 4).
Why is call recommended over send or transfer now?
call forwards all gas and returns success status, allowing better control and compatibility with smart contracts (see execution_table row 3).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, which method automatically reverts on failure without returning a success value?
Atransfer
Bsend
Ccall
DNone of the above
💡 Hint
Check the 'Success Check' column in row 1 of the execution_table.
At which step do you need to manually check the success boolean to handle failure?
AStep 3
BStep 1
CStep 2
DStep 4
💡 Hint
Look at the 'Success Check' and 'Result' columns for send in the execution_table.
If call returns false, what should your contract do?
AIgnore and continue
BHandle failure manually (e.g., revert or log)
CAutomatically succeed
DRetry sending Ether
💡 Hint
See the 'Result' column for call failure in the execution_table row 5.
Concept Snapshot
Sending Ether in Solidity:
- transfer: sends Ether, reverts on failure, no success bool
- send: sends Ether, returns bool success, must check manually
- call: recommended, returns (bool, data), must check success
- Always handle failure to avoid lost funds or bugs
Full Transcript
This visual execution shows how to send Ether in Solidity using transfer, send, and call methods. Transfer sends Ether and automatically reverts if it fails, so no success boolean is returned. Send returns a boolean success that must be checked manually to handle failure. Call is the recommended method now because it forwards all gas and returns a success boolean and data, allowing better control. The execution table traces each step, showing when to check success and how to handle failure. Variable tracking shows the recipient address, amount sent, and success status after each method. Key moments clarify why transfer doesn't return success, why send requires manual checks, and why call is preferred. The quiz tests understanding of these points. The snapshot summarizes the key rules for sending Ether safely.