1

I have one sentence in my code that is evaluating a condition. If the evaluation fail´s I throw a execption with assert and require. In my case I think that require is the indicated election for a boolean condition.

The exception is collected but testing between assert anf require the EVM return me two cain of message.

My problem is that I cant understand why return me this message.

It´s some mechanism to return a simple string with a error message?

**Assert response assert

**Require response require

1 Answer 1

1

Those message are not related to assert or require by themselves. May be you have some different problems, like gas limit setting too low or whatsoever.

Try to assess this replacing the assert/require conditions with something stable and work to obtain the desired results. Then put in your conditions.

In short use:

require(true);     // never reverts
require(false);    // always reverts
assert(true);       // never reverts
assert(false);     // always reverts

-> be sure to switch off any optimization!!!

until your contract compile and deploy as required, after that you can work on those require and assert you need.

By the way: you should use require when your condition can be met or not depending on data and runtime conditions, assert when your condition must be always true (or false), whichever be the general situation.

5
  • I increase the gas limit to double. I change the require to a fixed bool, I take off the optimization of the Remix and the problem persist... What I cant understand is why if the condition is true I get the answer that I want. And when the condition is false the transaction is rejected but the message is different. Nov 26, 2018 at 15:35
  • Share again the result when require do exist, but it is fixed to true (i.e. it do not revert)
    – Rick Park
    Nov 26, 2018 at 16:35
  • 1
    I add for your eventual reference: if the condition is true, the require permits to the code to continue the execution (next line shall be the next executed); if it is false, it stops the execution and revert. The same for assert.
    – Rick Park
    Nov 26, 2018 at 17:56
  • It seems that I have to add the message. require(isOwnerInHisTrace(_id), "You are no able to set this information"); Now when I force the error. The message appear. Thx!!! Nov 27, 2018 at 8:34
  • You are welcome.
    – Rick Park
    Nov 27, 2018 at 8:51

Your Answer

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

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