Lesson 4: msg.value passed to payable subfunctions? #562
-
At 5h27min, we send ethers to the function receive, that calls the function fund(). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@validydy This receive function is the special function that should be declared as payable, you read about it on solidity documentation. It executes on calls to the contract with no data ( calldata ), such as calls made via send() or transfer(). We have put the fund function inside receive so in case a user call contract (not fund function) with no data their amount (msg.value) should not be wasted and our fund function can take that amount and do the rest of the stuff. Hope it clears your query. |
Beta Was this translation helpful? Give feedback.
@validydy This receive function is the special function that should be declared as payable, you read about it on solidity documentation. It executes on calls to the contract with no data ( calldata ), such as calls made via send() or transfer().
We have put the fund function inside receive so in case a user call contract (not fund function) with no data their amount (msg.value) should not be wasted and our fund function can take that amount and do the rest of the stuff.
Hope it clears your query.