Lesson 4: Remix Fund Me #2602
-
Hi Community, Can you please help me figuring out if the block chain should allow such kind of transaction directly to smart contract and if yes what would be the issue here? Please, do let me know if it is safe to provide link to failed transaction if that will help figuring out the issue with transaction? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
@aviorn36 : Yes, you can provide your failed transactions No worry! |
Beta Was this translation helpful? Give feedback.
-
Hey @aviorn36 for your contract to receive/hold ETH, there has to be atleast one function marked
This is enough. Or you could go an extra mile and add a
|
Beta Was this translation helpful? Give feedback.
Hey @aviorn36 for your contract to receive/hold ETH, there has to be atleast one function marked
payable
In our case, it was thefund()
function. However, in scenarios like the one you have where you want to send funds directly without using thefund
function, we need to come up with a default function that sort of receives the funds. In you case, since you didn't set a fallback function, that's why you encountered an error because there is no way contract can sort of, hold/receive the funds you are sending to it. So if you don't want to use thefund
function as the main way you send money into this contract, you have to set apayable
fallback
orreceive
function that will do just that. I…