Skip to main content

Divergent

A divergent instruction is an instruction that fails. The effect of a failing instruction is to cancel all modifications (storage, operations) executed by the entrypoint so far. Hence a failing operation does not change anything on the contract state.

The only effect of a failing injected operation is that the operation fee is spent and not paid back. That's why the correct process is to simulate (dry run) the entrypoint before injection to make sure the entrypoint does not fail (as wallets do for example).

fail(e : T)

Aborts entrypoint execution with value e.

Parameter


e :

T

value to fail with (of any packable type).

fail_some(e : option<T>)

Aborts entrypoint if optional value e is some value.

It is equivalent to:

match e with
| some(v) -> fail(v)
| none -> ()
end

Parameter


Option of any packable type

Fails with

t

Fails with value t when e = some(t)


Michelson

do_require(t : bool, e : T)

Aborts entrypoint if test expression t is false.

It is equivalent to:

if not t then
fail(e)

Parameters


t :

Boolean expression required to be true.


e :

T

value to fail with (of any packable type) when t is false.

Fails with

e


Michelson


Related

do_fail_if(t : bool, e : T)

Aborts entrypoint if test expression t is true.

It is equivalent to:

if t then
fail(e)

Parameters


t :

Boolean expression required to be false.


e :

T

value to fail with (of any type) when t is true.

Fails with

e


Michelson


Related