In my smart contract, I want to check whether a boolean value is true, if not the smart contract should abort or throw an error like
(begin
(require-true value)
...continue
)
How can I do that?
In my smart contract, I want to check whether a boolean value is true, if not the smart contract should abort or throw an error like
(begin
(require-true value)
...continue
)
How can I do that?
asserts!
will return true and continue the execution only if the boolean expression it evaluates is true. If not it will return the thrown-value and exit the current control flow.Signature is:
(asserts! boolean-expression thrown-value)
Example that will return
true
and continue execution:(asserts! (is-eq 1 1) (err 1))