Macro near_sdk::require

source ·
macro_rules! require {
    ($cond:expr $(,)?) => { ... };
    ($cond:expr, $message:expr $(,)?) => { ... };
}
Expand description

Helper macro to create assertions that will panic through the runtime host functions.

This macro can be used similarly to assert! but will reduce code size by not including file and rust specific data in the panic message.

§Examples

use near_sdk::require;

let a = 2;
require!(a > 0);
require!("test" != "other", "Some custom error message if false");