Skip to content

Lesson 4: msg.value passed to payable subfunctions? #562

Answered by alymurtazamemon
validydy asked this question in Q&A
Discussion options

You must be logged in to vote

@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.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@validydy
Comment options

@alymurtazamemon
Comment options

Answer selected by validydy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants