Can I have a modifier that enforces the amount sent by a user in a call to a function, and if it is below a certain amount, throw? I want to do something like the following:

 uint256 n;

// Set some amount n in the constructor...

modifier checkAmount() payable {
    if(msg.value < n) throw;

2 Answers 2


No, you can make your function payable but not the modifier. To note -Payable itself is a modifier.

However, you can use both payable and custom modifier while defining your function and keep msg.value check in the modifier "checkAmount" to throw in case it is less than defined value(n).

  • Should we place payable keyword in font of checkAmount modifier in this case, in order for checkAmount to use msg.value? Jun 4, 2018 at 17:17

No, modifier not receiving any ether, You can check if (msg.value < n) throw in your payable function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.