Skip to content

Lesson 9: Passing an argument to a function raffle.enterRaffle() with no parameters #2542

Answered by othaime-en
tsuccar asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @tsuccar

  1. You are right, the enterRaffle function does not take any parameters, however, it is payable and has to receive some ETH before allowing anybody to enter the raffle as evidenced by the snippet below.
if (msg.value < i_entranceFee) {
            revert Raffle__NotEnoughETHEntered();
    }

As we know, we have to pay some eth when calling the enterRaffle function for us to enter the raffle and the method used in the code above it how we send eth with our transactions (Yes. Calling a function is a transaction). So in this case, {value: entranceFee + 1} isn't really a parameter, more like a value/data that we send along with our transaction. When we send like this, the eth beco…

Replies: 1 comment 2 replies

Comment options

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

@krakxn
Comment options

Answer selected by tsuccar
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