Lesson 9: Hardhat Smart Contract Lottery ((bool success, )) #2623
-
Hi! (bool success, ) = recentWinner.call{value: address(this).balance}(""); contracts/Raffle.sol What is it mean? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In solidity, we use the
|
Beta Was this translation helpful? Give feedback.
In solidity, we use the
.call
functionality as one way to send funds from one account to another. In this case, we are sendingaddress(this).balance
(the balance of our contract) to therecentWinner
. Using.call
returns two parameters and the first is a TRUE/FALSE value depending on whether the transaction (sending funds to the recentWinner) has suceeded or failed. We then store this value in abool
type variable calledsuccess
Afterwards in the next lines of code, we check to see if the
success
value was true or false. If it was false, meaning that the transaction failed then we can throw an error and revert saying that the transaction failed