fundMe contract - payable function #317
-
Hello, guys! My doubt is regarding the function above: I thought that the Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The payable keyword will not force you to send funds while deploying. Adding the payable keyword in the function's signature will allow us to receive msg.value (funds) inside that function. require on the other hand will verify that either we have sent the required amount, if not then will throw error (message on the right side). |
Beta Was this translation helpful? Give feedback.
-
If you want to add funds when deploying it, you could mark the constructor as payable and pass the amount as an argument. Make sure you have a withdraw function when sending eth to your contract. |
Beta Was this translation helpful? Give feedback.
@minchillo4
The payable keyword will not force you to send funds while deploying.
Adding the payable keyword in the function's signature will allow us to receive msg.value (funds) inside that function.
require on the other hand will verify that either we have sent the required amount, if not then will throw error (message on the right side).