0
0
Blockchain / Solidityprogramming~10 mins

Sending Ether (transfer, send, call) in Blockchain / Solidity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to send 1 ether using the transfer method.

Blockchain / Solidity
payable(msg.sender).[1](1 ether);
Drag options to blanks, or click blank then click option'
Acall
Bsend
CsendValue
Dtransfer
Attempts:
3 left
💡 Hint
Common Mistakes
Using send instead of transfer without checking return value.
2fill in blank
medium

Complete the code to send 0.5 ether using the send method and check success.

Blockchain / Solidity
bool success = payable(receiver).[1](0.5 ether);
Drag options to blanks, or click blank then click option'
Atransfer
Bcall
Csend
DsendValue
Attempts:
3 left
💡 Hint
Common Mistakes
Not checking the boolean result of send.
3fill in blank
hard

Fix the error in sending Ether using call and check for success.

Blockchain / Solidity
(bool sent, ) = payable(receiver).[1]{value: amount}(''); require(sent, 'Failed to send Ether');
Drag options to blanks, or click blank then click option'
Acall
Btransfer
Csend
DsendValue
Attempts:
3 left
💡 Hint
Common Mistakes
Using transfer or send with call syntax.
4fill in blank
hard

Fill both blanks to send Ether safely using call and handle failure.

Blockchain / Solidity
([1], ) = payable(receiver).[2]{value: msg.value}(''); require([1], 'Send failed');
Drag options to blanks, or click blank then click option'
Asent
Bsend
Ccall
Dtransfer
Attempts:
3 left
💡 Hint
Common Mistakes
Using transfer or send with call syntax.
5fill in blank
hard

Fill all three blanks to create a function that sends Ether using call and reverts on failure.

Blockchain / Solidity
function sendEther(address payable receiver) public payable { (bool [1], bytes memory [2]) = receiver.[3]{value: msg.value}(''); require([1], 'Failed to send Ether'); }
Drag options to blanks, or click blank then click option'
Asuccess
Bdata
Ccall
Dsend
Attempts:
3 left
💡 Hint
Common Mistakes
Using send or transfer instead of call in this pattern.