Skip to content

why do we need receive() function at all, why not use fallback() everywhere? #35

Answered by PatrickAlphaC
SrikanthAlva asked this question in Q&A
Discussion options

You must be logged in to vote

Long story short:

You may want your contract to act differently when you are sent ether vs sent data. You could 100% always use the fallback, but it'll be a little more gas efficient if you do have different functionality to have both. Otherwise, you'd have to do some data validation in your fallback to check for data.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

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

@SrikanthAlva
Comment options

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