Bird
Raised Fist0
Blockchain / Solidityprogramming~10 mins

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

Choose your learning style10 modes available
Concept Flow - Sending Ether (transfer, send, call)
Start Transaction
↓
Choose Method
↓
transfer
↓
Check success?
No→Revert 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.

Practice

(1/5)
1.

Which Solidity function automatically reverts the transaction if sending Ether fails?

easy
A. approve
B. send
C. call
D. transfer

Solution

  1. Step 1: Understand transfer behavior

    transfer sends Ether and automatically reverts if the transfer fails.
  2. Step 2: Compare with other methods

    send returns false on failure without reverting; call requires manual check; approve is unrelated to sending Ether.
  3. Final Answer:

    transfer -> Option D
  4. Quick Check:

    Automatic revert on failure = transfer [OK]
Hint: transfer always reverts on failure, no manual check needed [OK]
Common Mistakes:
  • Confusing send with transfer behavior
  • Thinking call auto-reverts on failure
  • Mixing approve with Ether sending
2.

Which of the following is the correct syntax to send 1 Ether using send in Solidity?

recipient.?{value: 1 ether}();
easy
A. send
B. transfer
C. call
D. approve

Solution

  1. Step 1: Recall send syntax

    send is called as recipient.send{value: amount}() in Solidity 0.6+.
  2. Step 2: Match syntax with options

    Only send matches send method usage for sending Ether.
  3. Final Answer:

    send -> Option A
  4. Quick Check:

    send syntax = recipient.send{value: 1 ether}() [OK]
Hint: send uses .send{value: amount}() syntax [OK]
Common Mistakes:
  • Using transfer syntax with send
  • Confusing call syntax with send
  • Using approve which is unrelated
3.

What will be the output of the following Solidity code snippet?

bool success = recipient.send{value: 1 ether}();
if (!success) {
    revert("Send failed");
}
medium
A. Transaction reverts if send fails
B. Transaction always succeeds without revert
C. Compilation error due to syntax
D. Transaction succeeds but ignores failure

Solution

  1. Step 1: Analyze send return value

    send returns false if sending Ether fails, but does not revert automatically.
  2. Step 2: Check revert condition

    The code checks !success and calls revert manually, so transaction reverts on failure.
  3. Final Answer:

    Transaction reverts if send fails -> Option A
  4. Quick Check:

    send returns false + manual revert = revert on failure [OK]
Hint: send returns bool; revert manually on false [OK]
Common Mistakes:
  • Assuming send auto-reverts
  • Ignoring manual revert check
  • Thinking code always succeeds
4.

Identify the error in this Solidity code snippet that uses call to send Ether:

(bool sent, ) = recipient.call{value: 1 ether}();
require(sent, "Failed to send Ether");
medium
A. Missing gas parameter in call
B. Incorrect syntax for call
C. No error; code is correct
D. Should use send instead of call

Solution

  1. Step 1: Review call syntax

    The syntax recipient.call{value: 1 ether}() is correct for sending Ether with call.
  2. Step 2: Check error handling

    The code checks sent boolean and reverts if false, which is proper error handling.
  3. Final Answer:

    No error; code is correct -> Option C
  4. Quick Check:

    call with value + require check = correct usage [OK]
Hint: call needs manual success check; this code does it [OK]
Common Mistakes:
  • Thinking gas parameter is mandatory
  • Confusing call syntax with send or transfer
  • Ignoring manual success check
5.

You want to send Ether to a contract that might consume more than 2300 gas on fallback. Which method should you use to ensure the transfer succeeds?

hard
A. transfer
B. call
C. approve
D. send

Solution

  1. Step 1: Understand gas limits of transfer and send

    transfer and send forward only 2300 gas, which may be insufficient for complex fallback functions.
  2. Step 2: Use call for flexible gas forwarding

    call allows forwarding all available gas, ensuring the receiving contract can execute complex logic.
  3. Final Answer:

    call -> Option B
  4. Quick Check:

    call forwards all gas, suitable for complex fallback [OK]
Hint: Use call to forward all gas for complex fallback [OK]
Common Mistakes:
  • Using transfer or send which limit gas to 2300
  • Confusing approve with sending Ether
  • Ignoring fallback gas requirements
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard