Skip to content
Discussion options

You must be logged in to vote

Hi @rasyidred, good question.

When working with ETH, one technique to limit the amount sent with msg.value in a function is by using require().

Here's an example, limiting the amount of ETH sent:

function depositETH() public payable {
   require(msg.value >= 0.1 ether && msg.value <= 1 ether, "Amount must be 0.1 - 1 ETH");
   // continue function 
}

Replies: 1 comment 2 replies

Comment options

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

@rasyidred
Comment options

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