[][src]Macro elrond_wasm::require

macro_rules! require {
    ($expression:expr, $error_msg:expr) => { ... };
}

Allows us to write Solidity style require!(<condition>, <error_msg>) and avoid if statements.

It can only be used in a function that returns SCResult<_> where _ can be any type.

fn only_callable_by_owner(&self) -> SCResult<()> {
    require!(self.get_caller() == self.get_owner_address(), "Caller must be owner");
    Ok(())
}