receive function #2663
-
in this video at 5:27:00 send eth 0.02>50$ from metamask to contract address. And apply a require statement to check if receive() external payble{ while require statement inside fund() function so revert will not effect to transfer eth/fund to contract address. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@Naveed-Jameel Not actually, Yes it is true that the gas cost will be deducted till the required statement for computation and if the statement gets failed then the remaining gas will be refunded back, but the value that we are sending will only be added to the contract when we pass the statement. As you can see we are storing |
Beta Was this translation helpful? Give feedback.
-
I do not quite understand your question. Please elaborate w/ a snippet. Also, look into @alymurtazamemon 's response! |
Beta Was this translation helpful? Give feedback.
@Naveed-Jameel Not actually, Yes it is true that the gas cost will be deducted till the required statement for computation and if the statement gets failed then the remaining gas will be refunded back, but the value that we are sending will only be added to the contract when we pass the statement. As you can see we are storing
msg.value
to sender mapping after it.