1

Is there a possibility to change a state variable and then throw an error, so that the state is maintained. e.g.:

uint minAmount = 1 ether;
uint state;
function payDeposit() payable {
    if(msg.value < minAmount ) {
        state = 2;
        throw;
    }
    state = 1;
 }

In the example above, the state variable is not set. Is there any way to solve this problem?

1 Answer 1

1

It is not possible, since throw ensures that there are no side effects of the call remain and all gas is consumed.

1
  • I belivev you could use one of require(msg.value < minAmount or assert(msg.value < minAmount) ...I forget which of the two will maintain state.
    – theruss
    Apr 23, 2018 at 19:51

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.